るりまサーチ

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

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. zlib end

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

String#%(args) -> String (18251.0)

printf と同じ規則に従って args をフォーマットします。

...ist[例][ruby]{
p "i = %d" % 10 # => "i = 10"
p "i = %x" % 10 # => "i = a"
p "i = %o" % 10 # => "i = 12"

p "i = %#d" % 10 # => "i = 10"
p "i = %#x" % 10 # => "i = 0xa"
p "i = %#o" % 10 # => "i = 012"

p "%d" % 10 # => "10"
p "%d,%o" % [10, 10] # => "10,12...
...ないこと、2進数の指示子(%b, %B)が存在すること、sprintf のすべての方言をサ
ポートしていないこと(%': 3桁区切り)などの違いがあります。

Ruby には整数の大きさに上限がないので、%b, %B, %o, %x, %X
に負の数を与えると (左側に...
...るためには %+x、% x のように指定します。


以下は sprintf フォーマットの書式です。[] で囲まれた部分は省略可
能であることを示しています。

%
[nth$][フラグ][幅][.精度]指示子
%
[<name>][フラグ][幅][.精度]指示子

`%' 自身を出...

Array#pack(template) -> String (223.0)

配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。

...、整数サイズ非依存 (ネットワークプロトコルなどに適切)
//emlist{
n: big endian unsigned 16bit
N: big endian unsigned 32bit
v: little endian unsigned 16bit
V: little endian unsigned 32bit
//}

: エンディアン依存、整数サイズ依存 (C の構造体などに...
...ィアンの強制指定(バイナリ解析などに適切)
//emlist{
S>: big endian unsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}

=== 各テンプレート文字の説明

説明中、Array#p...
...ber)
end

elsif exp == 255
if fra == 0
sgn * Inf # ±∞ (positive/negative infinity)
else
NaN # 非数 (not a number)
end

else
fra += 1 << 23 # ゲタ
sgn * fra * 2**(exp-127-23) # 正規化数 (normalized number)
end

//}...

Array#pack(template, buffer: String.new) -> String (223.0)

配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。

...、整数サイズ非依存 (ネットワークプロトコルなどに適切)
//emlist{
n: big endian unsigned 16bit
N: big endian unsigned 32bit
v: little endian unsigned 16bit
V: little endian unsigned 32bit
//}

: エンディアン依存、整数サイズ依存 (C の構造体などに...
...ィアンの強制指定(バイナリ解析などに適切)
//emlist{
S>: big endian unsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}

=== 各テンプレート文字の説明

説明中、Array#p...
...ber)
end

elsif exp == 255
if fra == 0
sgn * Inf # ±∞ (positive/negative infinity)
else
NaN # 非数 (not a number)
end

else
fra += 1 << 23 # ゲタ
sgn * fra * 2**(exp-127-23) # 正規化数 (normalized number)
end

//}...

String#unpack(template) -> Array (223.0)

Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。

...、整数サイズ非依存 (ネットワークプロトコルなどに適切)
//emlist{
n: big endian unsigned 16bit
N: big endian unsigned 32bit
v: little endian unsigned 16bit
V: little endian unsigned 32bit
//}

: エンディアン依存、整数サイズ依存 (C の構造体などに...
...ィアンの強制指定(バイナリ解析などに適切)
//emlist{
S>: big endian unsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}

=== 各テンプレート文字の説明

説明中、Array#p...
...ber)
end

elsif exp == 255
if fra == 0
sgn * Inf # ±∞ (positive/negative infinity)
else
NaN # 非数 (not a number)
end

else
fra += 1 << 23 # ゲタ
sgn * fra * 2**(exp-127-23) # 正規化数 (normalized number)
end

//}...

BasicObject#method_missing(name, *args) -> object (43.0)

呼びだされたメソッドが定義されていなかった時、Rubyインタプリタがこのメソッド を呼び出します。

...a = data
end

def method_missing(name, lang)
if name.to_s =~ /\Afind_(\d+)_in\z/
if @data[lang]
p @data[lang][$1.to_i]
else
raise "#{lang} unknown"
end

else
super
end

end

end


dic = Foo.new({:English => %w(zero one two), :Esperanto => %w(nulo...

絞り込み条件を変える

Object#enum_for(method = :each, *args) -> Enumerator (43.0)

Enumerator.new(self, method, *args) を返します。

...am args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[...
...# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end

end

each do |*val|
n.times { yield *val }
end

end

end


%
i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
#...

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (43.0)

Enumerator.new(self, method, *args) を返します。

...am args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[...
...# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end

end

each do |*val|
n.times { yield *val }
end

end

end


%
i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
#...

Object#to_enum(method = :each, *args) -> Enumerator (43.0)

Enumerator.new(self, method, *args) を返します。

...am args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[...
...# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end

end

each do |*val|
n.times { yield *val }
end

end

end


%
i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
#...

Object#to_enum(method = :each, *args) {|*args| ... } -> Enumerator (43.0)

Enumerator.new(self, method, *args) を返します。

...am args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[...
...# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end

end

each do |*val|
n.times { yield *val }
end

end

end


%
i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
#...
<< 1 2 3 ... > >>