るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Module#<(other) -> bool | nil (18179.0)

比較演算子。self が other の子孫である場合、 true を返します。 self が other の先祖か同一のクラス/モジュールである場合、false を返します。

...す。

@
param other 比較対象のモジュールやクラス

@
raise TypeError other がクラスやモジュールではない場合に発生します。

//emlist[例][ruby]{
module Foo
end

class Bar
include Foo
end

class Baz < Bar
end

class Qux
end

p Bar < Foo # => true
p Baz < Bar #...
...=> true
p Baz < Foo # => true
p Baz < Qux # => nil
p Baz > Qux # => nil

p Foo < Object.new # => in `<': compared with non class/module (TypeError)
//}...

Method#<<(callable) -> Proc (6161.0)

self と引数を合成した Proc を返します。

...呼び出しの順序が逆になります。

@
param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。

//emlist[例][ruby]{
def f(x)
x * x
end


def g(x)
x + x
end


# (3 + 3) * (3 + 3)
p (method(:f) << method(:g)).call(3) # => 36
//}

//emlist[cal...
...例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end

end


File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT

pipeline = method(:pp) << WordScanner << File.method(:read)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}

@
see Proc#<<, Pro...

Module#<=(other) -> bool | nil (6143.0)

比較演算子。self が other の子孫であるか、self と other が 同一クラスである場合、 true を返します。 self が other の先祖である場合、false を返します。

...

@
param other 比較対象のモジュールやクラス

@
raise TypeError other がクラスやモジュールではない場合に発生します。

@
see Module#<

//emlist[例][ruby]{
module Foo; end
module Bar
include Foo
end

module Baz
prepend Foo
end


Bar.ancestors # => [Bar, Foo]
Foo <=...
...Bar # => false
Bar <= Foo # => true

Baz.ancestors # => [Foo, Baz]
Foo <= Baz # => false
Baz <= Foo # => true

Foo <= Foo # => true
Foo <= Object # => nil
//}...

Module#<=>(other) -> Integer | nil (6143.0)

self と other の継承関係を比較します。

...

@
param other 比較対象のクラスやモジュール

//emlist[例][ruby]{
module Foo
end

class Bar
include Foo
end

class Baz < Bar
end

class Qux
end

p Bar <=> Foo # => -1
p Baz <=> Bar # => -1
p Baz <=> Foo # => -1
p Baz <=> Qux # => nil
p Qux <=> Baz # => nil

p Baz <=>...

Proc#<<(callable) -> Proc (6143.0)

self と引数を合成した Proc を返します。

...

@
param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。

//emlist[例][ruby]{
f = proc { |x| x * x }
g = proc { |x| x + x }

# (3 + 3) * (3 + 3)
p (f << g).call(3) # => 36
//}

//emlist[call を定義したオブジェクトを渡す例][ruby]{
c...
...anner
def self.call(str)
str.scan(/\w+/)
end

end


File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT

pipeline = proc { |data| puts "word count: #{data.size}" } << WordScanner << File.method(:read)
pipeline.call('testfile') # => word count: 4
//}

@
see Method#<<, Method#>>...

絞り込み条件を変える

CSV#<<(row) -> self (6131.0)

自身に row を追加します。

...ん。

@
param row 配列か CSV::Row のインスタンスを指定します。
CSV::Row のインスタンスが指定された場合は、CSV::Row#fields の値
のみが追加されます。

//emlist[例 配列を指定][ruby]{
require "csv"

File.write("test.csv", <<CSV)...
...ro", "kondo", "34"])
end


print File.read("test.csv")
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21
# 5,saburo,kondo,34
//}

//emlist[例 CSV::Row を指定][ruby]{
require "csv"

File.write("test.csv", <<CSV)
id,first name,l...
...CSV.open("test.csv", "a") do |csv|
row = CSV::Row.new(["id", "first name", "last name", "age"], ["5", "saburo", "kondo", "34"])
csv.add_row(row)
end


print File.read("test.csv")
# => "id", first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,...

CSV#add_row(row) -> self (3031.0)

自身に row を追加します。

...ん。

@
param row 配列か CSV::Row のインスタンスを指定します。
CSV::Row のインスタンスが指定された場合は、CSV::Row#fields の値
のみが追加されます。

//emlist[例 配列を指定][ruby]{
require "csv"

File.write("test.csv", <<CSV)...
...ro", "kondo", "34"])
end


print File.read("test.csv")
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21
# 5,saburo,kondo,34
//}

//emlist[例 CSV::Row を指定][ruby]{
require "csv"

File.write("test.csv", <<CSV)
id,first name,l...
...CSV.open("test.csv", "a") do |csv|
row = CSV::Row.new(["id", "first name", "last name", "age"], ["5", "saburo", "kondo", "34"])
csv.add_row(row)
end


print File.read("test.csv")
# => "id", first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,...

CSV#puts(row) -> self (3031.0)

自身に row を追加します。

...ん。

@
param row 配列か CSV::Row のインスタンスを指定します。
CSV::Row のインスタンスが指定された場合は、CSV::Row#fields の値
のみが追加されます。

//emlist[例 配列を指定][ruby]{
require "csv"

File.write("test.csv", <<CSV)...
...ro", "kondo", "34"])
end


print File.read("test.csv")
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21
# 5,saburo,kondo,34
//}

//emlist[例 CSV::Row を指定][ruby]{
require "csv"

File.write("test.csv", <<CSV)
id,first name,l...
...CSV.open("test.csv", "a") do |csv|
row = CSV::Row.new(["id", "first name", "last name", "age"], ["5", "saburo", "kondo", "34"])
csv.add_row(row)
end


print File.read("test.csv")
# => "id", first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,...

RubyVM::InstructionSequence#base_label -> String (3025.0)

self が表す命令シーケンスの基本ラベルを返します。

...iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.base_label
# => "<compiled>"

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/method.rb
def hello
puts "hello, world"
end


# irb...
...> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.base_label # => "<main>"

例3:

# /tmp/method2.rb
def hello
puts "hello, world"
end


Ruby
VM::InstructionSequence.of(method(:hello)).base_label
# => "hello"

@
see RubyVM::InstructionSequence#label...

RubyVM::InstructionSequence#label -> String (3025.0)

self が表す命令シーケンスのラベルを返します。通常、メソッド名、クラス名、 モジュール名などで構成されます。

...では "<main>" を返します。self を文字列から作成していた場合
は "<compiled>" を返します。

例1:irb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.label
# => "<compiled...
...>"

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/method.rb
def hello
puts "hello, world"
end


# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.label # => "<main>"

例3:

# /tmp/method2.rb
def hello
puts "hello,...
...world"
end

Ruby
VM::InstructionSequence.of(method(:hello)).label
# => "hello"

@
see RubyVM::InstructionSequence#base_label...

絞り込み条件を変える

<< 1 2 3 ... > >>