るりまサーチ

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

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. matrix t
  4. t61string new
  5. fiddle type_size_t

ライブラリ

クラス

キーワード

検索結果

ARGF.class#puts(*arg) -> nil (24220.0)

引数と改行を順番に処理対象のファイルに出力します。 引数がなければ改行のみを出力します。

...力します。
引数がなければ改行のみを出力します。

c:ARGF#inplace時にのみ使用できます。
また $stdout への代入の影響を受けません。
それ以外は Kernel.#puts と同じです。

@
param arg 出力するオブジェクトを任意個指定します。...

Time#deconstruct_keys(array_of_names_or_nil) -> Hash (6173.0)

パターンマッチに使用する名前と値の Hash を返します。

...month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :subsec
* :dst
* :zone

@
param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。

//emlist[例][ruby]{
t
= Time.utc(2...
...if t in wday: 3, day: ..7 # deconstruct_keys が使われます
puts
"first Wednesday of the month"
end
#=> "first Wednesday of the month" が出力される

case t
in year: ...2022
puts
"too old"
in month: ..9
puts
"quarter 1-3"
in wday: 1..5, month:
puts
"working day in month #{month}"...
...end
#=> "working day in month 10" が出力される

# クラスのチェックと組み合わせて利用することもできます
if t in Time(wday: 3, day: ..7)
puts
"first Wednesday of the month"
end
//}

@
see d:spec/pattern_matching#matching_non_primitive_objects...

Date#deconstruct_keys(array_of_names_or_nil) -> Hash (6149.0)

パターンマッチに使用する名前と値の Hash を返します。

...:month
* :day
* :yday
* :wday

@
param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。

//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
puts
"too old"
in month: ..9
puts
"quarter 1-3"
in wday: 1..5, month:
puts
"working day in month #{month}"
end
#=> "working day in month 10" が出力さ...
...れる

# クラスのチェックと組み合わせて利用することもできます
if d in Date(wday: 3, day: ..7)
puts
"first Wednesday of the month"
end
//}

@
see d:spec/pattern_matching#matching_non_primitive_objects...

DateTime#deconstruct_keys(array_of_names_or_nil) -> Hash (6149.0)

パターンマッチに使用する名前と値の Hash を返します。

...:month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :sec_fraction
* :zone

@
param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。

//emlist[例][ruby]{
dt = DateTime.n...
...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
puts
"quarter 1-3"
in wday: 1..5, month:
puts
"working day in month #{month}"
end
#=> "working day in mont...
...h 10" が出力される

# クラスのチェックと組み合わせて利用することもできます
if dt in DateTime(wday: 1..5, hour: 10..18, day: ..7)
puts
"Working time, first week of the month"
end
//}

@
see d:spec/pattern_matching#matching_non_primitive_objects...

Module#alias_method(new, original) -> Symbol (6149.0)

メソッドの別名を定義します。

...メソッドの別名を定義します。

//emlist[例][ruby]{
module Kernel
alias_method :hoge, :puts # => :hoge
alias_method "foo", :puts # => :foo
end
//}

alias との違いは以下の通りです。

* メソッド名は String または Symbol で指定します
* グローバル...
...

@
param new 新しいメソッド名。String または Symbol で指定します。

@
param original 元のメソッド名。String または Symbol で指定します。

@
return 作成したエイリアスのメソッド名を表す Symbol を返します。

@
see d:spec/def#alias

//emlist[...
...例][ruby]{
module Kernel
alias_method :foo, :puts
end

foo "bar" # bar
//}...

絞り込み条件を変える

Data#deconstruct_keys(array_of_names_or_nil) -> Hash (6143.0)

self のメンバの名前と値の組を Hash で返します。

...と値の組を 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" が表...
...se distance
in Measure(amount:, unit: 'km')
puts
"It is #{amount} kilometers away"
# ...
end
//}

@
param array_of_names_or_nil 返り値に含めるメンバの名前の配列を指定します。nil の場合は全てのメンバを意味します。

[注意] 本メソッドの記述は Data の...

Module#alias_method(new, original) -> self (6143.0)

メソッドの別名を定義します。

...メソッドの別名を定義します。

//emlist[例][ruby]{
module Kernel
alias_method :hoge, :puts # => Kernel
end
//}

alias との違いは以下の通りです。

* メソッド名は String または Symbol で指定します
* グローバル変数の別名をつけることはで...
...

@
param new 新しいメソッド名。String または Symbol で指定します。

@
param original 元のメソッド名。String または Symbol で指定します。

@
return self を返します。

@
see d:spec/def#alias

//emlist[例][ruby]{
module Kernel
alias_method :foo, :puts
end...

Data#deconstruct -> [object] (6137.0)

self のメンバの値を配列で返します。

...

//emlist[例][ruby]{
Measure = Data.define(:amount, :unit)

distance = Measure.new(10, 'km')
distance.deconstruct # => [10, "km"]
//}

このメソッドは以下のようにパターンマッチで利用されます。

//emlist[例][ruby]{
Measure = Data.define(:amount, :unit)
distance = Meas...
...')

case distance
in n, 'km' # 裏側で #deconstruct を呼ぶ
puts
"It is #{n} kilometers away"
else
puts
"Don't know how to handle it"
end
# "It is 10 kilometers away" が表示される

# 以下のようにも書ける
case distance
in Measure(n, 'km')
puts
"It is #{n} kilometers away"
#...
......
end
//}

[注意] 本メソッドの記述は Data のサブクラスのインスタンスに対して呼び
出す事を想定しています。Data.define は Data のサブクラスを作成する点に
注意してください。

@
see d:spec/pattern_matching#matching_non_primitive_objects...

CSV::Row#deconstruct_keys(keys) -> Hash (6131.0)

パターンマッチに使用するヘッダの名前と値の Hash を返します。

...はキーをシンボルに変換する必要があります。

@
param keys パターンマッチに使用するヘッダの名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。

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

row = CSV::Row.new([:header1, :hea...
.... }
puts
"all 2 or more"
in { header1: ...2, header2: 2.., header3: 2.. }
puts
"first column is less than 2, and rest columns are 2 or more"
end
#=> "first column is less than 2, and rest columns are 2 or more" が出力される
//}

@
see d:spec/pattern_matching#matching_non_primitive_objects...

BasicObject#singleton_method_undefined(name) -> object (6125.0)

特異メソッドが Module#undef_method または undef により未定義にされた時にインタプリタから呼び出されます。

...特異メソッドが Module#undef_method または
undef により未定義にされた時にインタプリタから呼び出されます。

通常のメソッドの未定義に対するフックには
Module#method_undefined を使います。

@
param name 未定義にされたメソッド名...
...list[例][ruby]{
class Foo
def singleton_method_undefined(name)
puts
"singleton method \"#{name}\" was undefined"
end
end

obj = Foo.new
def obj.foo
end
def obj.bar
end

class << obj
undef_method :foo
end
obj.instance_eval {undef bar}

#=> singleton method "foo" was undefined
# singleton...
...method "bar" was undefined
//}

@
see Module#method_undefined,BasicObject#singleton_method_added,BasicObject#singleton_method_removed , d:spec/def#undef...

絞り込み条件を変える

CSV::Row#deconstruct -> [object] (6125.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 2, and rest columns are...
...2 or more" が出力される
//}

@
see d:spec/pattern_matching#matching_non_primitive_objects...

Object#===(other) -> bool (3159.0)

case 式で使用されるメソッドです。d:spec/control#case も参照してください。

...用されるメソッドです。d:spec/control#case も参照してください。

このメソッドは case 式での振る舞いを考慮して、
各クラスの性質に合わせて再定義すべきです。

デフォルトでは内部で Object#== を呼び出します。

when 節の式...
...

@
param other 比較するオブジェクトです。

//emlist[][ruby]{
age = 12
# (0..2).===(12), (3..6).===(12), ... が実行される
result =
case age
when 0 .. 2
"baby"
when 3 .. 6
"little child"
when 7 .. 12
"child"
when 13 .. 18
"youth"
else
"adult"
end...
...uts result #=> "child"

def check arg
case arg
when /ruby(?!\s*on\s*rails)/i
"hit! #{arg}"
when String
"Instance of String class. But don't hit."
else
"unknown"
end
end

puts
check([]) #=> unknown
puts
check("mash-up in Ruby on Rails") #=> instance of String class. But not hit....