るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

BasicObject#! -> bool (18304.0)

オブジェクトを真偽値として評価し、その論理否定を返します。

... Ruby の制御式において nil や false 以外が偽として
扱われることはありません。

@
return オブジェクトが偽であれば真、さもなくば偽

//emlist[例][ruby]{
class NegationRecorder < BasicObject
def initialize
@
count = 0
end
attr_reader :count...
...def !
@
count += 1
super
end
end

recorder = NegationRecorder.new
!
recorder
!
!!!!!!recorder
puts 'hoge' if !recorder

puts recorder.count #=> 3
//}

//emlist[例][ruby]{
class AnotherFalse < BasicObject
def !
true
end
end
another_false = AnotherFalse.new

# another_falseは*真*
p...

BasicObject#!=(other) -> bool (6261.0)

オブジェクトが other と等しくないことを判定します。

...返します。
このため、サブクラスで BasicObject#== を再定義しても != とは自動的に整合性が
とれるようになっています。

ただし、 BasicObject#!= 自身や BasicObject#! を再定義した際には、ユーザーの責任で
整合性を保たなくては...
...と想定されています。

@
param other 比較対象となるオブジェクト
@
see BasicObject#==, BasicObject#!

//emlist[例][ruby]{
class NonequalityRecorder < BasicObject
def initialize
@
count = 0
end
attr_reader :count

def !=(other)
@
count += 1
super
end
end
record...
...er = NonequalityRecorder.new

recorder != 1
puts 'hoge' if recorder != "str"

p recorder.count #=> 2
//}...

CSV::Table#by_col_or_row! -> self (6244.0)

自身をミックスモードに変更します。

...

@
return 必ず自身を返すので安全にメソッドチェーンできます。

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

row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
table = CSV::Table.new([row1, row2]).by_col!...
...table # => #<CSV::Table mode:col row_count:3>
table.by_col_or_row!
table # => #<CSV::Table mode:col_or_row row_count:3>
//}...

CSV::Table#by_row! -> self (6238.0)

自身をロウモードに変更します。

...びモードが変更されるまで、いくつかのメソッドは行単位で動きます。

@
return 必ず自身を返すので安全にメソッドチェーンできます。

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

row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row2 = CSV::Row...
...], ["row2_1", "row2_2"])
table = CSV::Table.new([row1, row2])
table # => #<CSV::Table mode:col_or_row row_count:3>
table.by_row!
table # => #<CSV::Table mode:row row_count:3>
table[0] # => #<CSV::Row "header1":"row1_1" "header2":"row1_2">
table[1] # => #<CSV::Row "header1":"row2_1" "...

Proc#<<(callable) -> Proc (173.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#>>...

絞り込み条件を変える