Tbpgr Blog

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

2014-04-15から1日間の記事一覧

Ruby | 指定した値が二次元配列に含まれているか確認する

概要 指定した値が二次元配列に含まれているか確認する 詳細 tbpgr_utils gemのArray#together_include?(別名でtinclude?もあり) 指定した値が二次元配列に含まれているか確認します。 デフォルトでは、複数ある配列のどれか1つに含まれていればtrueを返却…

Ruby | 二次元配列の各先頭要素を取得する

概要 二次元配列の各先頭要素を取得する 詳細 tbpgr_utils gemのArray#together_first(別名でtfirstもあり) 二次元配列の各先頭要素を取得します。 事前準備 gem install tbpgr_utils 主な用途 二次元配列の各先頭要素を取得したいとき。 サンプルコード #…

TbpgrUtils | 追加要件 Numeric to_hex_html_table 追加

概要 追加要件 Numeric to_hex_html_table 追加 詳細 追加要件 Numeric to_hex_html_table 仕様 ・10/16進数をHTMLの表形式の文字列で取得します ※より詳細についてはGitHubのREADMEおよびテストケース参照 GitHub https://github.com/tbpgr/tbpgr_utils Rub…

RSpec | rspec-core shared examples

概要 rspec-core shared examples 詳細 shared examplesは複数のexample間で共有するexampleを定義できます。 include_examplesで呼び出します。 alias main alias shared_examples shared_context shared_examples shared_examples_for include_examples in…

RSpec | rspec-core metadata

概要 rspec-core shared metadata 詳細 metadata RSpecのexample.metadataはメタデータをハッシュで保持している。 described_class described_classでdescribeのクラスを取得可能。 shared_examlesなどを作成する際に、 処理対象のクラス名称を問わずに利用…

RSpec | rspec-core describe/context/it/example/specify

概要 rspec-core describe/context/it/example/specify 詳細 describe describeはExampleGroupを生成します。 it describeの内側で、itメソッドを利用してexampleを作成できます。 alias main alias memo describe context トップレベルではdescribeのみ利用…

Ruby | Integer | even?

概要 Integer#even? 詳細 数値が偶数か判定します。 サンプルコード # encoding: utf-8 (1..10).each { |v| puts "#{v} is even? :#{v.even?} " } 出力 1 is even? :false 2 is even? :true 3 is even? :false 4 is even? :true 5 is even? :false 6 is even…