Tbpgr Blog

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

2012-06-12から1日間の記事一覧

書籍 Ruby Cookbook | eRuby

パンくず Ruby Cookbook eRuby 概要 eRuby eRuby eRubyによるテンプレート処理について。 eRubuy=JSPと同じ動きをすると思って差し支えない。 テンプレートとなるテキストにスクリプトレットでRubyのコードを埋め込んで 実行することができる。 サンプル req…

書籍 Ruby Cookbook | 変数を含む文字列とエスケープ

パンくず Ruby Cookbook 変数を含む文字列とエスケープ 概要 変数を含む文字列とエスケープ 変数を含む文字列とエスケープ 以下の構文で文字列内に変数を埋め込むことが出来ます。 hoge = "test" "#{hoge}!!" # => test!!と出力 この際、#{variable}の部分を…

書籍 Ruby Cookbook | Array#join

パンくず Ruby Cookbook Array#Join 概要 Array#join Array#Join Array#joinメソッドに文字列を指定することで、 指定文字列を間に挟んで、配列内の文字列連結を行います。 サンプル csv_columns = %w[one two three] puts csv_columns.join(",") # =>each文…

書籍 Ruby Cookbook | Predicate Method

パンくず Ruby Cookbook Predicate Method 概要 Predicate Method Predicate Method Predicate Method=述語メソッドRubyでは真偽値を返すメソッド=述語メソッドは末尾に?をつけます サンプル puts "".empty? # => true puts "hoge".empty? # => false # 自…

書籍 Ruby Cookbook | Immutable MethodとDestroy Method

パンくず Ruby Cookbook Immutable MethodとDestroy Method 概要 Immutable MethodとDestroy Method Immutable MethodとDestroy Method Immutable Method=不変なメソッド Destroy Method=破壊的なメソッド前者はオブジェクトの値を変えない。 後者はオブジ…

書籍 Ruby Cookbook | Stringの頭一文字を取得

パンくず Ruby Cookbook Stringの頭一文字を取得 概要 Stringの頭一文字を取得 サンプル hoge = "hoge" puts hoge.chr #=>hを返す

書籍 Ruby Cookbook

概要 書籍 Ruby Cookbookに関するメモ。 全てをカバーせず、自分の中で新たに学ぶことやまとめ直しておきたいことのみを抜粋します。 また、例示するサンプルも写経せずに出来るだけ自分で考えたサンプルにします。 各章 Chapter1. String Stringの頭一文字…