ライブラリ
- ビルトイン (497)
- csv (42)
- date (4)
-
fiddle
/ import (96) -
json
/ add / ostruct (12) -
json
/ add / struct (12) - mkmf (24)
- openssl (36)
- ostruct (173)
- rake (12)
-
rexml
/ document (96) -
rexml
/ parsers / pullparser (12) -
rexml
/ sax2listener (12) -
rexml
/ streamlistener (12) - socket (60)
クラス
- Addrinfo (24)
- Array (31)
- CSV (36)
-
CSV
:: Row (6) - Data (6)
- Date (2)
- DateTime (2)
-
Fiddle
:: CStruct (24) - Hash (10)
- MatchData (4)
-
OpenSSL
:: ASN1 :: Constructive (36) - OpenStruct (185)
-
REXML
:: Element (12) -
REXML
:: Instruction (84) -
REXML
:: Parsers :: PullEvent (12) -
Rake
:: Application (12) -
RubyVM
:: InstructionSequence (130) -
Socket
:: Option (36) - String (12)
- Struct (307)
- Time (2)
- TracePoint (7)
モジュール
-
Fiddle
:: Importer (72) - Kernel (24)
-
REXML
:: SAX2Listener (12) -
REXML
:: StreamListener (12)
キーワード
- == (36)
- [] (24)
- []= (24)
-
absolute
_ path (12) -
base
_ label (12) - clone (12)
- content (12)
- content= (12)
- convert (36)
-
create
_ value (12) - data (12)
- deconstruct (14)
-
deconstruct
_ keys (20) -
delete
_ field (12) - dig (40)
- disasm (12)
- disassemble (12)
- each (36)
-
each
_ pair (48) - eql? (24)
- equal? (12)
- eval (12)
- filter (14)
-
first
_ lineno (12) - hash (24)
-
have
_ struct _ member (24) - inspect (36)
- instruction (12)
- instruction? (12)
-
instruction
_ sequence (7) - instructions (12)
- label (12)
- length (12)
- linger (12)
- members (12)
- modifiable (12)
-
new
_ ostruct _ member (12) -
node
_ type (12) - pack (21)
- path (12)
-
processing
_ instruction (12) - select (24)
- size (12)
- sizeof (12)
- tagging (12)
- tagging= (12)
- target (12)
- target= (12)
-
to
_ a (24) -
to
_ binary (10) -
to
_ h (38) -
to
_ i (12) -
to
_ json (24) -
to
_ ptr (12) -
to
_ s (48) -
to
_ sockaddr (12) - typealias (12)
- union (12)
- unpack (12)
- value (12)
- values (12)
-
values
_ at (12)
検索結果
先頭5件
-
Struct
# values _ at(*members) -> [object] (9025.0) -
引数で指定されたメンバの値の配列を返します。
...]{
Foo = Struct.new(:foo, :bar, :baz)
obj = Foo.new('FOO', 'BAR', 'BAZ')
p obj.values_at(0, 1, 2) # => ["FOO", "BAR", "BAZ"]
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下... -
Struct
# dig(key , . . . ) -> object | nil (9007.0) -
self 以下のネストしたオブジェクトを dig メソッドで再帰的に参照して返し ます。途中のオブジェクトが nil であった場合は nil を返します。
...場合は nil を返します。
@param key キーを任意個指定します。
//emlist[例][ruby]{
klass = Struct.new(:a)
o = klass.new(klass.new({b: [1, 2, 3]}))
o.dig(:a, :a, :b, 0) # => 1
o.dig(:b, 0) # => nil
//}
@see Array#dig, Hash#dig, OpenStruct#dig... -
Struct
# to _ json(*args) -> String (9007.0) -
自身を JSON 形式の文字列に変換して返します。
...引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json に渡されます。
//emlist[例][ruby]{
require "json/add/core"
Person = Struct.new(:name, :age)
Person.new("tanaka", 29).to_json # => "{\"json_class\":\"Person\",\"v\":[\"tanaka\",29]}"
//}
@see JSON::Generator::GeneratorMe... -
REXML
:: StreamListener # instruction(name , instruction) -> () (6201.0) -
XML処理命令(PI)をパースしたときに呼び出されるコールバックメソッドです。
...e ターゲット名が文字列で渡されます
@param instruction 処理命令の内容が文字列で渡されます
=== 例
<?xml-stylesheet type="text/css" href="style.css"?>
というPIに対し
name: "xml-stylesheet"
instruction: " type=\"text/css\" href=\"style.css\""
という引... -
TracePoint
# instruction _ sequence -> RubyVM :: InstructionSequence (6201.0) -
script_compiledイベント発生時にコンパイルされた RubyVM::InstructionSequenceインスタンスを返します。
...compiledイベント発生時にコンパイルされた
RubyVM::InstructionSequenceインスタンスを返します。
//emlist[例][ruby]{
TracePoint.new(:script_compiled) do |tp|
p tp.instruction_sequence # => <RubyVM::InstructionSequence:block in <main>@(eval):1>
end.enable do
eval("puts '... -
Kernel
# have _ struct _ member(type , member , headers = nil) -> bool (6121.0) -
member というメンバを持つ構造体 type がシステムに存在するかどうか検査します。
...を持つ構造体 type が存在しない場合は、偽を返します。
例えば
require 'mkmf'
have_struct_member('struct foo', 'bar') # => true
である場合、HAVE_STRUCT_FOO_BAR というプリプロセッサマクロをコンパイラに渡します。
また、後方互換性の... -
Kernel
# have _ struct _ member(type , member , headers = nil) { . . . } -> bool (6121.0) -
member というメンバを持つ構造体 type がシステムに存在するかどうか検査します。
...を持つ構造体 type が存在しない場合は、偽を返します。
例えば
require 'mkmf'
have_struct_member('struct foo', 'bar') # => true
である場合、HAVE_STRUCT_FOO_BAR というプリプロセッサマクロをコンパイラに渡します。
また、後方互換性の... -
CSV
:: Row # deconstruct -> [object] (6101.0) -
パターンマッチに使用する行の値の配列を返します。
パターンマッチに使用する行の値の配列を返します。
//emlist[例][ruby]{
require "csv"
row = CSV::Row.new(["header1", "header2", "header3"], [1, 2, 3])
case row
in [2.., 2.., 2..]
puts "all 2 or more"
in [...2, 2.., 2..]
puts "first column is less than 2, and rest columns are 2 or more"
end
#=> "first column is less than ... -
CSV
:: Row # deconstruct _ keys(keys) -> Hash (6101.0) -
パターンマッチに使用するヘッダの名前と値の Hash を返します。
パターンマッチに使用するヘッダの名前と値の Hash を返します。
このメソッドはヘッダ名の型をシンボルに変換しないため、ヘッダ名が文字列かつ Hash パターン でパターンマッチしたい場合はキーをシンボルに変換する必要があります。
@param keys パターンマッチに使用するヘッダの名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{
require "csv"
row = CSV::Row.new([:header1, :header2, :header3], [1, 2, 3])
case row
in { hea... -
Data
# deconstruct -> [object] (6101.0) -
self のメンバの値を配列で返します。
..., 'km')
distance.deconstruct # => [10, "km"]
//}
このメソッドは以下のようにパターンマッチで利用されます。
//emlist[例][ruby]{
Measure = Data.define(:amount, :unit)
distance = Measure.new(10, 'km')
case distance
in n, 'km' # 裏側で #deconstruct を呼ぶ
puts "It... -
Data
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (6101.0) -
self のメンバの名前と値の組を Hash で返します。
...。
//emlist[例][ruby]{
Measure = Data.define(:amount, :unit)
distance = Measure.new(10, 'km')
distance.deconstruct_keys(nil) # => {:amount=>10, :unit=>"km"}
distance.deconstruct_keys([:amount]) # => {:amount=>10}
//}
このメソッドは以下のようにパターンマッチで利用さ....../emlist[例][ruby]{
Measure = Data.define(:amount, :unit)
distance = Measure.new(10, 'km')
case distance
in amount:, unit: 'km' # 裏側で #deconstruct_keys を呼ぶ
puts "It is #{amount} kilometers away"
else
puts "Don't know how to handle it"
end
# "It is 10 kilometers away" が表示され... -
Date
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (6101.0) -
パターンマッチに使用する名前と値の Hash を返します。
...の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{
d = Date.new(2022, 10, 5)
if d in wday: 3, day: ..7 # deconstruct_keys が使われます
puts "first Wednesday of the month"
end
#=> "first Wednesday of the month" が出力される
case d
in year: ...2022... -
DateTime
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (6101.0) -
パターンマッチに使用する名前と値の Hash を返します。
...パターンマッチに使用します。
//emlist[例][ruby]{
dt = DateTime.new(2022, 10, 5, 13, 30)
if dt in wday: 1..5, hour: 10..18 # deconstruct_keys が使われます
puts "Working time"
end
#=> "Working time" が出力される
case dt
in year: ...2022
puts "too old"
in month: ..9... -
MatchData
# deconstruct _ keys(array _ of _ names) -> Hash (6101.0) -
引数で指定された名前の名前付きキャプチャを Hash で返します。
...//emlist[例][ruby]{
m = /(?<hours>\d{2}):(?<minutes>\d{2}):(?<seconds>\d{2})/.match("18:37:22")
m.deconstruct_keys([:hours, :minutes]) # => {:hours => "18", :minutes => "37"}
m.deconstruct_keys(nil) # => {:hours => "18", :minutes => "37", :seconds => "22"}
# 名前付きキャプチャが定義......されていなかった場合は空のハッシュを返す
m = /(\d{2}):(\d{2}):(\d{2})/.match("18:37:22")
m.deconstruct_keys(nil) # => {}
//}
@see d:spec/pattern_matching#matching_non_primitive_objects... -
REXML
:: Element # instructions -> [REXML :: Instraction] (6101.0) -
すべての instruction 子ノードの配列を返します。
...すべての instruction 子ノードの配列を返します。
返される配列は freeze されます。...