別のキーワード
クラス
-
CSV
:: Table (12) - Data (12)
- DateTime (60)
- IO (12)
- Object (12)
-
RubyVM
:: InstructionSequence (12) - Struct (16)
- SystemCallError (12)
モジュール
- FileUtils (12)
- Psych (14)
-
RubyVM
:: AbstractSyntaxTree (10)
キーワード
- === (12)
- [] (10)
- civil (12)
- commercial (12)
-
copy
_ stream (12) - jd (12)
- new (42)
- ordinal (12)
-
safe
_ load (14) -
yaml
_ tag (12)
検索結果
先頭5件
- RubyVM
:: InstructionSequence . of(body) -> RubyVM :: InstructionSequence - RubyVM
:: AbstractSyntaxTree . of(proc) -> RubyVM :: AbstractSyntaxTree :: Node - RubyVM
:: AbstractSyntaxTree . of(proc , keep _ script _ lines: false , error _ tolerant: false , keep _ tokens: false) -> RubyVM :: AbstractSyntaxTree :: Node - RubyVM
:: AbstractSyntaxTree . of(proc) -> RubyVM :: AbstractSyntaxTree :: Node - IO
. copy _ stream(src , dst , copy _ length , src _ offset) -> Integer
-
RubyVM
:: InstructionSequence . of(body) -> RubyVM :: InstructionSequence (21238.0) -
引数 body で指定した Proc、Method オブジェクトを元に RubyVM::InstructionSequence オブジェクトを作成して返します。
...数 body で指定した Proc、Method オブジェクトを元に
RubyVM::InstructionSequence オブジェクトを作成して返します。
@param body Proc、Method オブジェクトを指定します。
例1:irb で実行した場合
# proc
> p = proc { num = 1 + 2 }
> RubyVM::Instru......ctionSequence.of(p)
> # => <RubyVM::InstructionSequence:block in irb_binding@(irb)>
# method
> def foo(bar); puts bar; end
> RubyVM::InstructionSequence.of(method(:foo))
> # => <RubyVM::InstructionSequence:foo@(irb)>
例2: RubyVM::InstructionSequence.compile_file を使用した場合......}
# irb
> require '/tmp/iseq_of.rb'
# hello メソッド
> RubyVM::InstructionSequence.of(method(:hello))
> # => #<RubyVM::InstructionSequence:0x007fb73d7cb1d0>
# グローバル proc
> RubyVM::InstructionSequence.of($a_global_proc)
> # => #<RubyVM::InstructionSequence:0x007fb73d... -
RubyVM
:: AbstractSyntaxTree . of(proc) -> RubyVM :: AbstractSyntaxTree :: Node (21215.0) -
引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。
...が発生した際にエラー箇所を type が :ERROR であるようなノードに置き換えてツリーを生成します。
//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:......40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))
def hello
puts "hello, world"
end
pp RubyVM::AbstractSyntaxTree.of(method(:hello))
# => (SCOPE@5:0-7:3
# tbl: []
# args:
# (ARGS@5:9-5:9
# pre_num: 0
# pre_init: nil
# opt: nil
# first_post: ni......l
# post_num: 0
# post_init: nil
# rest: nil
# kw: nil
# kwrest: nil
# block: nil)
# body:
# (FCALL@6:2-6:21 :puts (LIST@6:7-6:21 (STR@6:7-6:21 "hello, world") nil)))
//}... -
RubyVM
:: AbstractSyntaxTree . of(proc , keep _ script _ lines: false , error _ tolerant: false , keep _ tokens: false) -> RubyVM :: AbstractSyntaxTree :: Node (21215.0) -
引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。
...が発生した際にエラー箇所を type が :ERROR であるようなノードに置き換えてツリーを生成します。
//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:......40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))
def hello
puts "hello, world"
end
pp RubyVM::AbstractSyntaxTree.of(method(:hello))
# => (SCOPE@5:0-7:3
# tbl: []
# args:
# (ARGS@5:9-5:9
# pre_num: 0
# pre_init: nil
# opt: nil
# first_post: ni......l
# post_num: 0
# post_init: nil
# rest: nil
# kw: nil
# kwrest: nil
# block: nil)
# body:
# (FCALL@6:2-6:21 :puts (LIST@6:7-6:21 (STR@6:7-6:21 "hello, world") nil)))
//}... -
RubyVM
:: AbstractSyntaxTree . of(proc) -> RubyVM :: AbstractSyntaxTree :: Node (21214.0) -
引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。
...st[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))
def hello
puts "hello, world"
end
pp RubyVM::AbstractSyntaxTree.of(method(......pre_num: 0
# pre_init: nil
# opt: nil
# first_post: nil
# post_num: 0
# post_init: nil
# rest: nil
# kw: nil
# kwrest: nil
# block: nil)
# body:
# (FCALL@6:2-6:21 :puts (LIST@6:7-6:21 (STR@6:7-6:21 "hello, world") nil)))
//}... -
IO
. copy _ stream(src , dst , copy _ length , src _ offset) -> Integer (6301.0) -
指定された src から dst へコピーします。 コピーしたバイト数を返します。
...ルは作成されます。ファイルが存在する場合は長さ 0 に切り詰められます。
src が IO オブジェクトでかつ src_offset が指定されている場合、
src のオフセット(src.pos)は変更されません。
@param src コピー元となる IO オブジェク......を指定します。
@param copy_length コピーする長さをバイト単位で指定します。最大 copy_length までコピーされます。
nil を指定した場合、コピーする長さに制限はありません。
@param src_offset コピーを始めるオフ......で指定します。
//emlist[例][ruby]{
IO.write("filetest", "abcdefghij")
IO.copy_stream("filetest", "filecopy", 2) # => 2
IO.read("filecopy") # => "ab"
IO.copy_stream("filetest", "filecopy", 3, 4) # => 3
IO.read("filecopy") # => "efg"
//... -
FileUtils
. options _ of(mid) -> Array (6208.0) -
与えられたメソッド名で使用可能なオプション名の配列を返します。
...与えられたメソッド名で使用可能なオプション名の配列を返します。
@param mid メソッド名を指定します。
//emlist[][ruby]{
require 'fileutils'
FileUtils.options_of(:rm) # => ["noop", "verbose", "force"]
//}... -
Object
. yaml _ tag(tag) -> () (6107.0) -
クラスと tag の間を関連付けます。
...これによって tag 付けされた YAML ドキュメントを Ruby のオブジェクトに
変換したりその逆をしたりすることができます。
@param tag 対象のクラスに関連付けるタグの文字列
=== Example
require 'psych'
class Foo
def initialize(x)......attr_reader :x
end
# Dumps Ruby object normally
p Psych.dump(Foo.new(3))
# =>
# --- !ruby/object:Foo
# x: 3
# Registers tag with class Foo
Foo.yaml_as("tag:example.com,2013:foo")
# ... and dumps the object of Foo class
Psych.dump(Foo.new(3), STDOUT)
# =>
# ---......!<tag:example.com,2013:foo>
# x: 3
# Loads the object from the tagged YAML node
p Psych.load(<<EOS)
--- !<tag:example.com,2012:foo>
x: 8
EOS
# => #<Foo:0x0000000130f48 @x=8>... -
Psych
. safe _ load(yaml , legacy _ permitted _ classes=[] , legacy _ permitted _ symbols=[] , legacy _ aliases=false , legacy _ filename=nil) -> object (3107.0) -
安全に YAML フォーマットの文書を読み込み Ruby のオブジェクトを生成して返します。
...安全に YAML フォーマットの文書を読み込み Ruby のオブジェクトを生成して返します。
デフォルトでは以下のクラスのオブジェクトしか変換しません。
* TrueClass
* FalseClass
* NilClass
* Numeric
* String
* Array
* Hash
再帰的なデ......][ruby]{
Psych.safe_load(yaml, permitted_classes: [Date])
//}
すると上のクラス一覧に加えて Date クラスが読み込まれます。
エイリアスはキーワード引数 aliases を指定することで明示的に許可できます。
//emlist[aliases: true の例][ruby]{
x = []......x << x
yaml = Psych.dump x
Psych.safe_load yaml # => 例外発生
Psych.safe_load yaml, aliases: true # => エイリアスが読み込まれる
//}
yaml に許可されていないクラスが含まれていた場合は、
Psych::DisallowedClass 例外が発生します。
yaml が... -
Psych
. safe _ load(yaml , permitted _ classes: [] , permitted _ symbols: [] , aliases: false , filename: nil , fallback: nil , symbolize _ names: false) -> object (3107.0) -
安全に YAML フォーマットの文書を読み込み Ruby のオブジェクトを生成して返します。
...安全に YAML フォーマットの文書を読み込み Ruby のオブジェクトを生成して返します。
デフォルトでは以下のクラスのオブジェクトしか変換しません。
* TrueClass
* FalseClass
* NilClass
* Numeric
* String
* Array
* Hash
再帰的なデ......][ruby]{
Psych.safe_load(yaml, permitted_classes: [Date])
//}
すると上のクラス一覧に加えて Date クラスが読み込まれます。
エイリアスはキーワード引数 aliases を指定することで明示的に許可できます。
//emlist[aliases: true の例][ruby]{
x = []......x << x
yaml = Psych.dump x
Psych.safe_load yaml # => 例外発生
Psych.safe_load yaml, aliases: true # => エイリアスが読み込まれる
//}
yaml に許可されていないクラスが含まれていた場合は、
Psych::DisallowedClass 例外が発生します。
yaml が... -
Psych
. safe _ load(yaml , permitted _ classes: [] , permitted _ symbols: [] , aliases: false , filename: nil , fallback: nil , symbolize _ names: false , freeze: false) -> object (3107.0) -
安全に YAML フォーマットの文書を読み込み Ruby のオブジェクトを生成して返します。
...安全に YAML フォーマットの文書を読み込み Ruby のオブジェクトを生成して返します。
デフォルトでは以下のクラスのオブジェクトしか変換しません。
* TrueClass
* FalseClass
* NilClass
* Numeric
* String
* Array
* Hash
再帰的なデ......][ruby]{
Psych.safe_load(yaml, permitted_classes: [Date])
//}
すると上のクラス一覧に加えて Date クラスが読み込まれます。
エイリアスはキーワード引数 aliases を指定することで明示的に許可できます。
//emlist[aliases: true の例][ruby]{
x = []......x << x
yaml = Psych.dump x
Psych.safe_load yaml # => 例外発生
Psych.safe_load yaml, aliases: true # => エイリアスが読み込まれる
//}
yaml に許可されていないクラスが含まれていた場合は、
Psych::DisallowedClass 例外が発生します。
yaml が... -
SystemCallError
. ===(other) -> bool (3007.0) -
other が SystemCallError のサブクラスのインスタンスで、 かつ、other.errno の値が self::Errno と同じ場合に真を返します。そうでない場合は偽を返します。
...other が SystemCallError のサブクラスのインスタンスで、
かつ、other.errno の値が self::Errno と同じ場合に真を返します。そうでない場合は偽を返します。
従って、特に other が self.kind_of?(other) である場合には Module#=== と同様に真......== Errno::EYYY::Errno である場合にも Errno::EXXX == Errno::EYYY.new は真を返します。
エラー名は異なるがエラーコードは同じであるような Errno::EXXX 例外をまとめて捕捉するために Module#=== を上書きしていました。
しかし、Ruby 1.8 の... -
Struct
. new(*args , keyword _ init: nil) -> Class (323.0) -
Struct クラスに新しいサブクラスを作って、それを返します。
...れを返します。
サブクラスでは構造体のメンバに対するアクセスメソッドが定義されています。
//emlist[例][ruby]{
dog = Struct.new("Dog", :name, :age)
fred = dog.new("fred", 5)
fred.age = 6
printf "name:%s age:%d", fred.name, fred.age
#=> "name:fred age:6" を......えた方が良いでしょう。
したがって、メンバ名は Symbol で指定するのが無難です。
@param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@param keyword_init 構造体クラスのインスタンスを生成する際......ruby]{
Point1 = Struct.new(:x, :y)
Point1.new(1, 2) # => #<struct Point1 x=1, y=2>
Point1.new(x: 1, y: 2) # => #<struct Point1 x=1, y=2>
Point1.new(x: 1) # => #<struct Point1 x=1, y=nil>
Point1.new(y: 2) # => #<struct Point1 x=nil, y=2>
Point1.new(x: 1, y: 2... -
Struct
. new(*args , keyword _ init: nil) {|subclass| block } -> Class (323.0) -
Struct クラスに新しいサブクラスを作って、それを返します。
...れを返します。
サブクラスでは構造体のメンバに対するアクセスメソッドが定義されています。
//emlist[例][ruby]{
dog = Struct.new("Dog", :name, :age)
fred = dog.new("fred", 5)
fred.age = 6
printf "name:%s age:%d", fred.name, fred.age
#=> "name:fred age:6" を......えた方が良いでしょう。
したがって、メンバ名は Symbol で指定するのが無難です。
@param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@param keyword_init 構造体クラスのインスタンスを生成する際......ruby]{
Point1 = Struct.new(:x, :y)
Point1.new(1, 2) # => #<struct Point1 x=1, y=2>
Point1.new(x: 1, y: 2) # => #<struct Point1 x=1, y=2>
Point1.new(x: 1) # => #<struct Point1 x=1, y=nil>
Point1.new(y: 2) # => #<struct Point1 x=nil, y=2>
Point1.new(x: 1, y: 2... -
CSV
:: Table . new(array _ of _ rows) -> CSV :: Table (208.0) -
自身を初期化します。
...期化します。
全ての行が同じヘッダを持つことを仮定しています。
@param array_of_rows CSV::Row のインスタンスの配列を指定します。
//emlist[例][ruby]{
require "csv"
row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row2 = CSV::Row.new([...