るりまサーチ

最速Rubyリファレンスマニュアル検索!
36件ヒット [1-36件を表示] (0.036秒)

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. io seek_end

ライブラリ

クラス

モジュール

キーワード

検索結果

CSV.generate(str = "", options = Hash.new) {|csv| ... } -> String (18114.0)

このメソッドは与えられた文字列をラップして CSV のオブジェクトとしてブロックに渡します。 ブロック内で CSV オブジェクトに行を追加することができます。 ブロックを評価した結果は文字列を返します。

...,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS

csv = CSV.generate(text, headers: true) do |csv|
csv.add_row(["5", "saburo", "kondo", "34"])
end


print csv
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yum...

JSON.create_id -> String (37.0)

json_create メソッドで使用するクラスを決定するために使用する値を返します。

...@name = id, name
end


def self.json_create(object)
new(object['id'], object["name"])
end


def as_json(*)
{
JSON.create_id => self.class.name,
"id" => id,
"name" => name,
}
end


def to_json(*)
as_json.to_json
end

end


json = JSON.generate(User.new(1, "t...

CSV.new(data, options = Hash.new) -> CSV (13.0)

このメソッドは CSV ファイルを読み込んだり、書き出したりするために String か IO のインスタンスをラップします。

...をラップします。

ラップされた文字列の先頭から読み込むことになります。
文字列に追記したい場合は CSV.generate を使用してください。
他の位置から処理したい場合はあらかじめそのように設定した StringIO を渡してくだ...
...r" の並びまでを読みます。
A sequence will be selected even if it occurs in a quoted field, assuming that you
would have the same line endings there. If none of those sequences is
found, +data+ is ARGF, Object::STDIN, Object::STDOUT, or
Object::STDERR, or the stream is only avail...
...manually if speed is important. Also
note that IO objects should be opened in binary mode on Windows if this
feature will be used as the line-ending translation can cause
problems with resetting the document position to where it was before the
read ahead. This String will be transcoded...