るりまサーチ

最速Rubyリファレンスマニュアル検索!
72件ヒット [1-72件を表示] (0.067秒)
トップページ > クエリ:ruby[x] > クエリ:string[x] > クエリ:parse[x] > 種類:モジュール関数[x]

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

モジュール

キーワード

検索結果

JSON.#unparse(object, state = nil) -> String (3233.0)

与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。

...また、循環参照のチェックを行います。JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成することもありません。

unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブジェクトを指定します。

@param state...
...文字列です。
: :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...
...ます。

@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...

JSON.#pretty_unparse(object, options = nil) -> String (3225.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 (3209.0)

与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。

...ることができるので、気をつけてください。

fast_unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブジェクトを指定します。

//emlist[例][ruby]{
require "json"

JSON.fast_generate({ name: "tanaka", age: 19 }) # => "...

Kernel.#caller(range) -> [String] | nil (146.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 (146.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 (146.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"]
//}...