るりまサーチ

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

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. irb/ext/use-loader irb_require
  4. rubygems/custom_require require
  5. require execute

検索結果

<< 1 2 > >>

Method#source_location -> [String, Integer] | nil (9031.0)

ソースコードのファイル名と行番号を配列で返します。

...@see Proc#source_location

//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class
Foo
def foo; end
end
# ----- end of /tmp/foo.rb ----

require
'/tmp/foo'

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m.source_location # => ["/tmp/foo.rb", 2]

method
(:puts).source_location # => nil
//}...

ERB#def_class(superklass=Object, methodname=&#39;erb&#39;) -> Class (6321.0)

変換した Ruby スクリプトをメソッドとして定義した無名のクラスを返します。

... methodname メソッド名

//emlist[例][ruby]{
require
'erb'

class
MyClass_
def initialize(arg1, arg2)
@arg1 = arg1; @arg2 = arg2
end
end
filename = 'example.rhtml' # @arg1 と @arg2 が使われている example.rhtml

erb = ERB.new(File.read(filename))
erb.filename = filename
MyClass...
...= erb.def_class(MyClass_, 'render()')
print MyClass.new('foo', 123).render()

# => test1foo
# test2123
//}...

JSON::Generator::GeneratorMethods::FalseClass#to_json(state_or_hash = nil) -> String (6007.0)

自身から生成した JSON 形式の文字列を返します。

...JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

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

false.to_json # => "false"
//}...

JSON::Generator::GeneratorMethods::NilClass#to_json(state_or_hash = nil) -> String (6007.0)

自身から生成した JSON 形式の文字列を返します。

...る JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

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

nil.to_json # => "null"
//}...

JSON::Generator::GeneratorMethods::TrueClass#to_json(state_or_hash = nil) -> String (6007.0)

自身から生成した JSON 形式の文字列を返します。

...る JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

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

true.to_json # => "true"
//}...

絞り込み条件を変える

JSON::Generator::GeneratorMethods::Object#to_json(state_or_hash = nil) -> String (3019.0)

自身を to_s で文字列にした結果を JSON 形式の文字列に変換して返します。

...例][ruby]{
require
"json"

class
Person
attr :name, :age

def initialize(name, age)
@name, @age = name, age
end
end

tanaka = Person.new("tanaka", 29)

tanaka.to_json # => "\"#<Person:0x00007ffdec0167c8>\""
tanaka.method(:to_json).owner # => JSON::Ext::Generator::GeneratorMethods::Object...

JSON::Generator::GeneratorMethods::String#to_json_raw_object -> Hash (3013.0)

生の文字列を格納したハッシュを生成します。

...UTF-8 の文字列ではなく生の文字列を JSON に変換する場合に使用してください。

require
'json'
"にほんご".encode("euc-jp").to_json_raw_object
# => {"json_class"=>"String", "raw"=>[164, 203, 164, 219, 164, 243, 164, 180]}
"にほんご".encode("euc-jp").to_json...

Forwardable#def_delegator(accessor, method, ali = method) -> () (229.0)

メソッドの委譲先を設定します。

...

@param accessor 委譲先のオブジェクト

@param method 委譲先のメソッド

@param ali 委譲元のメソッド

委譲元のオブジェクトで ali が呼び出された場合に、
委譲先のオブジェクトの method へ処理が委譲されるようになります。

...
...ます。

//emlist[例][ruby]{
require
'forwardable'

class
MyQueue
extend Forwardable
attr_reader :queue
def initialize
@queue = []
end

def_delegator :@queue, :push, :mypush
end

q = MyQueue.new
q.mypush 42
q.queue # => [42]
q.push 23 # => NoMethodError
//}

@see Forwardable#def...

Forwardable#def_instance_delegator(accessor, method, ali = method) -> () (229.0)

メソッドの委譲先を設定します。

...

@param accessor 委譲先のオブジェクト

@param method 委譲先のメソッド

@param ali 委譲元のメソッド

委譲元のオブジェクトで ali が呼び出された場合に、
委譲先のオブジェクトの method へ処理が委譲されるようになります。

...
...ます。

//emlist[例][ruby]{
require
'forwardable'

class
MyQueue
extend Forwardable
attr_reader :queue
def initialize
@queue = []
end

def_delegator :@queue, :push, :mypush
end

q = MyQueue.new
q.mypush 42
q.queue # => [42]
q.push 23 # => NoMethodError
//}

@see Forwardable#def...
<< 1 2 > >>