Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

2014-05-08から1日間の記事一覧

TbpgrUtils | 追加要件 Array#average 追加

概要 追加要件 Array#average 追加 詳細 追加要件 Array#average 仕様 ・Arrayの各要素が数値の場合に平均を返却します。 ※より詳細についてはGitHubのREADMEおよびテストケース参照 GitHub https://github.com/tbpgr/tbpgr_utils Rubygems http://rubygems.…

Ruby | lambda と Array と Hash を同時に処理するメソッドを作ってみる

概要 lambda と Array と Hash を同時に処理するメソッドを作ってみる 詳細 別に何の役にも立たないと思いますが、 lambda と Array と Hashは全て [] でダックタイピングできるので試してみます。 サンプルコード def no_principled(lambda_array_hash, arg…

Ruby | Collecting Inputs | Replace "string typing" with classes

概要 Replace "string typing" with classes 前提 Confident Rubyではメソッド内の処理を次のように分類しています。 ・Collecting Inputs(引数チェック、変換など) ・Performing Work(主処理) ・Delivering Output(戻り値に関わる処理) ・Handling Failur…

Ruby | Collecting Inputs | Define conversion functions

概要 Define conversion functions 前提 Confident Rubyではメソッド内の処理を次のように分類しています。 ・Collecting Inputs(引数チェック、変換など) ・Performing Work(主処理) ・Delivering Output(戻り値に関わる処理) ・Handling Failure(例外処…

Ruby | Collecting Inputs | Use built-in conversion functions

概要 Use built-in conversion functions 前提 Confident Rubyではメソッド内の処理を次のように分類しています。 ・Collecting Inputs(引数チェック、変換など) ・Performing Work(主処理) ・Delivering Output(戻り値に関わる処理) ・Handling Failure(…

Ruby | Collecting Inputs | Define conversions to user-defined types

概要 Define conversions to user-defined types 前提 Confident Rubyではメソッド内の処理を次のように分類しています。 ・Collecting Inputs(引数チェック、変換など) ・Performing Work(主処理) ・Delivering Output(戻り値に関わる処理) ・Handling Fa…

Ruby | Collecting Inputs | Define your own conversion protocols

概要 Define your own conversion protocols 前提 Confident Rubyではメソッド内の処理を次のように分類しています。 ・Collecting Inputs(引数チェック、変換など) ・Performing Work(主処理) ・Delivering Output(戻り値に関わる処理) ・Handling Failur…

Ruby | Collecting Inputs | Conditionally call conversion methods

概要 Conditionally call conversion methods 前提 Confident Rubyではメソッド内の処理を次のように分類しています。 ・Collecting Inputs(引数チェック、変換など) ・Performing Work(主処理) ・Delivering Output(戻り値に関わる処理) ・Handling Failu…

Ruby | Collecting Inputs | Use built-in conversion protocols

概要 Use built-in conversion protocols 前提 Confident Rubyではメソッド内の処理を次のように分類しています。 ・Collecting Inputs(引数チェック、変換など) ・Performing Work(主処理) ・Delivering Output(戻り値に関わる処理) ・Handling Failure(…

Ruby | Proc/lambdaとcallとcase

概要 Proc/lambdaとcallとcase 詳細 Proc/lambdaは通常呼び出し方には様々な形式があります。 self[*arg] -> ()[permalink][rdoc] call(*arg) -> () self === *arg -> () yield(*arg) -> () 「===」はcase whenを利用する際を想定して用意されています。 Pro…

Ruby | Module | module_function

概要 Module#module_function(*name) 詳細 メソッドをモジュール関数にします。 モジュール関数とは、インスタンスのprivateであるとともにモジュールの特異メソッドであるようなメソッドです。 例えばMathモジュールのメソッドは全てモジュール関数です。 …

Ruby | Kernel | caller

概要 Kernel#caller(start = 1) 詳細 メソッドのコールスタックを配列形式で返却する。 引数のstartに指定した要素数分取得する。 スタックの数を超えたstartを指定した場合はnilを返却する。 サンプルコード # encoding: utf-8 require 'pp' class Hoge def…