種類
- インスタンスメソッド (110)
- モジュール関数 (77)
- 特異メソッド (55)
- 文書 (15)
- クラス (11)
クラス
- Array (11)
- CSV (33)
-
JSON
:: State (99)
モジュール
- JSON (99)
キーワード
- CSV (11)
-
NEWS for Ruby 3
. 0 . 0 (4) - [] (11)
-
create
_ id (11) - dump (11)
-
fast
_ generate (11) -
fast
_ unparse (11) -
generate
_ line (11) - indent (11)
- indent= (11)
- new (11)
-
object
_ nl (11) -
object
_ nl= (11) -
pretty
_ generate (11) -
pretty
_ unparse (11) -
ruby 1
. 8 . 2 feature (11) - space (11)
- space= (11)
-
space
_ before (11) -
space
_ before= (11) -
to
_ csv (11) - unparse (11)
検索結果
先頭5件
-
JSON
. # generate(object , state = nil) -> String (18245.0) -
与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。
...文字列です。
: :space
a string that is put after, a : or , delimiter (default: '')
: :space_before
a string that is put before a : pair delimiter (default: '')
: :object_nl
a string that is put at the end of a JSON object (default: '')
: :array_nl
a string that is put at the end of a J......on"
JSON.generate([1, 2, { name: "tanaka", age: 19 }])
# => "[1,2,{\"name\":\"tanaka\",\"age\":19}]"
json_state = JSON::State.new(space: " ")
JSON.generate([1, 2, { name: "tanaka", age: 19 }], json_state)
# => "[1,2,{\"name\": \"tanaka\",\"age\": 19}]"
//}
@see JSON::State, JSON.#pretty_generate... -
CSV
. generate(str = "" , options = Hash . new) {|csv| . . . } -> String (18208.0) -
このメソッドは与えられた文字列をラップして CSV のオブジェクトとしてブロックに渡します。 ブロック内で CSV オブジェクトに行を追加することができます。 ブロックを評価した結果は文字列を返します。
...][ruby]{
require "csv"
text =<<-EOS
id,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... -
JSON
:: State # generate(obj) -> String (18202.0) -
Generates a valid JSON document from object obj and returns the result. If no valid JSON document can be created this method raises a GeneratorError exception.
...
Generates a valid JSON document from object obj and returns the
result. If no valid JSON document can be created this method raises a
GeneratorError exception.... -
JSON
. # pretty _ generate(object , options = nil) -> String (6239.0) -
Ruby のオブジェクトを JSON 形式の文字列に変換して返します。
...Ruby のオブジェクトを JSON 形式の文字列に変換して返します。
このメソッドは JSON.#generate よりも人間に読みやすい文字列を返します。
pretty_unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブ......JSON.#generate を参照してください。
//emlist[例][ruby]{
require "json"
hash = { "name": "tanaka", "age": 19 }
puts JSON.generate(hash)
# => {"name":"tanaka","age":19}
puts JSON.pretty_generate(hash)
# => {
# "name": "tanaka",
# "age": 19
# }
puts JSON.pretty_generate(hash......, space: "\t")
# => {
# "name": "tanaka",
# "age": 19
# }
//}
@see JSON.#generate... -
JSON
. # fast _ generate(object) -> String (6209.0) -
与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。
...けてください。
fast_unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブジェクトを指定します。
//emlist[例][ruby]{
require "json"
JSON.fast_generate({ name: "tanaka", age: 19 }) # => "{\"name\":\"tanaka\",\"age\":19}"
//}... -
CSV
. generate _ line(row , options = Hash . new) -> String (6208.0) -
このメソッドは一つの Array オブジェクトを CSV 文字列に変換するためのショートカットです。 複数行のCSVを扱う際はCSV#<<を使うとより高速です。
...コーディングを指定することができます。
:row_sep というキーの値には $/ がセットされます。
//emlist[例][ruby]{
require "csv"
taro = ['1', 'taro', 'tanaka', '20']
CSV.generate_line(taro, col_sep: '|') # => "1|taro|tanaka|20\n"
//}
@see CSV.new... -
JSON
. # unparse(object , state = nil) -> String (3145.0) -
与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。
...文字列です。
: :space
a string that is put after, a : or , delimiter (default: '')
: :space_before
a string that is put before a : pair delimiter (default: '')
: :object_nl
a string that is put at the end of a JSON object (default: '')
: :array_nl
a string that is put at the end of a J......on"
JSON.generate([1, 2, { name: "tanaka", age: 19 }])
# => "[1,2,{\"name\":\"tanaka\",\"age\":19}]"
json_state = JSON::State.new(space: " ")
JSON.generate([1, 2, { name: "tanaka", age: 19 }], json_state)
# => "[1,2,{\"name\": \"tanaka\",\"age\": 19}]"
//}
@see JSON::State, JSON.#pretty_generate... -
JSON
. # pretty _ unparse(object , options = nil) -> String (3139.0) -
Ruby のオブジェクトを JSON 形式の文字列に変換して返します。
...Ruby のオブジェクトを JSON 形式の文字列に変換して返します。
このメソッドは JSON.#generate よりも人間に読みやすい文字列を返します。
pretty_unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブ......JSON.#generate を参照してください。
//emlist[例][ruby]{
require "json"
hash = { "name": "tanaka", "age": 19 }
puts JSON.generate(hash)
# => {"name":"tanaka","age":19}
puts JSON.pretty_generate(hash)
# => {
# "name": "tanaka",
# "age": 19
# }
puts JSON.pretty_generate(hash......, space: "\t")
# => {
# "name": "tanaka",
# "age": 19
# }
//}
@see JSON.#generate... -
JSON
. # fast _ unparse(object) -> String (3109.0) -
与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。
...けてください。
fast_unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブジェクトを指定します。
//emlist[例][ruby]{
require "json"
JSON.fast_generate({ name: "tanaka", age: 19 }) # => "{\"name\":\"tanaka\",\"age\":19}"
//}... -
NEWS for Ruby 3
. 0 . 0 (264.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...", "f", 3]
in [*pre, String => x, String => y, *post]
p pre #=> ["a", 1]
p x #=> "b"
p y #=> "c"
p post #=> [2, "d", "e", "f", 3]
end
//}
* Endless method definition is added. [EXPERIMENTAL]
16746
//emlist{
def square(x) = x * x
//}
* Interpolated String literals are no lo......nger frozen when
`# frozen-string-literal: true` is used. 17104
* Magic comment `shareable_constant_value` added to freeze constants.
See {Magic Comments}[rdoc-ref:doc/syntax/comments.rdoc@Magic+Comments] for more details.
17273
* A {static analysis}[rdoc-label:label-Static+analysis]......rd`, `#to_i`, `#to_int`, `#zero?`
* `Struct`: reader methods for 10th or later members
* Constant references are inlined.
* Always generate appropriate code for `==`, `nil?`, and `!` calls depending on a receiver class.
* Reduce the number of PC accesses on branches and method re...