120件ヒット
[1-100件を表示]
(0.074秒)
別のキーワード
キーワード
- caller (36)
-
fast
_ unparse (12) -
load
_ file (12) -
load
_ file! (12) - parse! (12)
-
pretty
_ unparse (12) - unparse (12)
検索結果
先頭5件
-
JSON
. # parse(source , options = {}) -> object (18142.0) -
与えられた JSON 形式の文字列を Ruby オブジェクトに変換して返します。
...与えられた JSON 形式の文字列を Ruby オブジェクトに変換して返します。
@param source JSON 形式の文字列を指定します。
@param options オプションをハッシュで指定します。
指定可能なオプションは以下の通りです。
: :max_n......フォルトは偽です。
//emlist[例][ruby]{
require "json"
JSON.parse('[1,2,{"name":"tanaka","age":19}]')
# => [1, 2, {"name"=>"tanaka", "age"=>19}]
JSON.parse('[1,2,{"name":"tanaka","age":19}]', symbolize_names: true)
# => [1, 2, {:name=>"tanaka", :age=>19}]
//}
@see JSON::Parser#parse... -
JSON
. # parse!(source , options = {}) -> object (6154.0) -
与えられた JSON 形式の文字列を Ruby オブジェクトに変換して返します。
...与えられた JSON 形式の文字列を Ruby オブジェクトに変換して返します。
JSON.#parse よりも危険なデフォルト値が指定されているので
信頼できる文字列のみを入力として使用するようにしてください。
@param source JSON 形式の......す。
//emlist[例][ruby]{
require "json"
json_text = "[1,2,{\"name\":\"tanaka\",\"age\":19}, NaN]"
JSON.parse!(json_text)
# => [1, 2, {"name"=>"tanaka", "age"=>19}, NaN]
JSON.parse!(json_text, symbolize_names: true)
# => [1, 2, {:name=>"tanaka", :age=>19}, NaN]
JSON.parse(json_text) # => unexp......ected token at 'NaN]' (JSON::ParserError)
//}
@see JSON::Parser#parse... -
JSON
. # pretty _ unparse(object , options = nil) -> String (3123.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)... -
JSON
. # fast _ unparse(object) -> String (3107.0) -
与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。
...ることができるので、気をつけてください。
fast_unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブジェクトを指定します。
//emlist[例][ruby]{
require "json"
JSON.fast_generate({ name: "tanaka", age: 19 }) # => "... -
JSON
. # unparse(object , state = nil) -> String (3107.0) -
与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。
...また、循環参照のチェックを行います。JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成することもありません。
unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブジェクトを指定します。
@param state......ます。
@raise JSON::CircularDatastructure 与えられたオブジェクトが循環参照を持つ場合に発生します。
//emlist[例][ruby]{
require "json"
JSON.generate([1, 2, { name: "tanaka", age: 19 }])
# => "[1,2,{\"name\":\"tanaka\",\"age\":19}]"
json_state = JSON::State.new(space... -
Kernel
. # caller(range) -> [String] | nil (43.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...囲を示す Range オブジェクトを指定します。
@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations
//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'",......。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(caller.first)
end
def bar
foo
p parse_caller(caller.first)
end
bar
p parse_caller(caller.first)......=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。
//emlist[例][ruby]{
$DEBUG = true
def debug(*args)
p [caller.first, *args] if $DEBUG
end
debug "debug information"
#=> ["-:7", "debug information"]
//}... -
Kernel
. # caller(start = 1) -> [String] | nil (43.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...囲を示す Range オブジェクトを指定します。
@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations
//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'",......。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(caller.first)
end
def bar
foo
p parse_caller(caller.first)
end
bar
p parse_caller(caller.first)......=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。
//emlist[例][ruby]{
$DEBUG = true
def debug(*args)
p [caller.first, *args] if $DEBUG
end
debug "debug information"
#=> ["-:7", "debug information"]
//}... -
Kernel
. # caller(start , length) -> [String] | nil (43.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...囲を示す Range オブジェクトを指定します。
@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations
//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'",......。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(caller.first)
end
def bar
foo
p parse_caller(caller.first)
end
bar
p parse_caller(caller.first)......=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真の場合に役に立つ debug 関数
のサンプルです。
//emlist[例][ruby]{
$DEBUG = true
def debug(*args)
p [caller.first, *args] if $DEBUG
end
debug "debug information"
#=> ["-:7", "debug information"]
//}... -
JSON
. # load _ file!(filespec , opts = {}) -> object (29.0) -
filespec で指定した JSON 形式のファイルを Ruby オブジェクトとしてロードして返します。
...JSON 形式のファイルを Ruby オブジェクトとしてロードして返します。
@param filespec ファイル名を指定します。
@param options オプションをハッシュで指定します。指定可能なオプションは JSON.#parse! と同様です。
@see JSON.#parse!...