るりまサーチ

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

別のキーワード

  1. objectspace each_object
  2. _builtin each_object
  3. object send
  4. object to_enum
  5. object enum_for

検索結果

<< 1 2 3 ... > >>

BasicObject#! -> bool (21225.0)

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

...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は*真*
puts "another false is a truth" if another_false
#=> "another false is a truth"
//}...

Object#!~(other) -> bool (15200.0)

自身が other とマッチしない事を判定します。

...身が other とマッチしない事を判定します。

self#=~(obj) を反転した結果と同じ結果を返します。

@param other 判定するオブジェクトを指定します。

//emlist[例][ruby]{
obj = 'regexp'
p (obj !~ /re/) # => false

obj = nil
p (obj !~ /re/) # => true
//}...

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

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

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

ただし、 BasicObject#!= 自身や BasicObject#! を再定義した際には、ユーザーの責任で
整合性を保...
...@see BasicObject#==, BasicObject#!

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

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

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

p reco...
...rder.count #=> 2
//}...

Object.yaml_tag(tag) -> () (9148.0)

クラスと tag の間を関連付けます。

...umps Ruby object normally
p Psych.dump(Foo.new(3))
# =>
# --- !ruby/object:Foo
# x: 3

# Registers tag with class Foo
Foo.yaml_as("tag:example.com,2013:foo")
# ... and dumps the object of Foo class
Psych.dump(Foo.new(3), STDOUT)
# =>
# --- !<tag:example.com,2013:foo>
# x:...
...3

# Loads the object from the tagged YAML node
p Psych.load(<<EOS)
--- !<tag:example.com,2012:foo>
x: 8
EOS
# => #<Foo:0x0000000130f48 @x=8>...

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

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

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

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

when 節の式をレシーバーとして === を呼び出すことに注意してください。

また Enumerable...
...ult"
end

puts 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...
puts check("<Ruby's world>") #=> hit! <Ruby's world>
//}

@see Object#==, Range#===, Module#===, Regexp#===, Enumerable#grep...

絞り込み条件を変える

Array#slice!(nth) -> object | nil (6301.0)

指定した要素を自身から取り除き、取り除いた要素を返します。取り除く要素がなければ nil を返します。

...します。

@param nth 取り除く要素のインデックスを整数で指定します。

//emlist[例][ruby]{
a = [ "a", "b", "c" ]
a.slice!(1) #=> "b"
a #=> ["a", "c"]
a.slice!(-1) #=> "c"
a #=> ["a"]
a.slice!(100) #=> nil
a #=> ["a"]
//}...

JSON.#load_file!(filespec, opts = {}) -> object (6301.0)

filespec で指定した JSON 形式のファイルを Ruby オブジェクトとしてロードして返します。

...JSON 形式のファイルを Ruby オブジェクトとしてロードして返します。

@param filespec ファイル名を指定します。

@param options オプションをハッシュで指定します。指定可能なオプションは JSON.#parse! と同様です。

@see JSON.#parse!...

JSON.#parse!(source, options = {}) -> object (6301.0)

与えられた JSON 形式の文字列を Ruby オブジェクトに変換して返します。

...t = "[1,2,{\"name\":\"tanaka\",\"age\":19}, NaN]"
JSON.parse!(json_text)
# => [1, 2, {"name"=>"tanaka", "age"=>19}, NaN]

JSON.parse!(json_text, symbolize_names: true)
# => [1, 2, {:name=>"tanaka", :age=>19}, NaN]

JSON.parse(json_text) # => unexpected token at 'NaN]' (JSON::ParserError)
//}

@see J...

Array#slice!(range) -> Array | nil (6201.0)

指定した部分配列を自身から取り除き、取り除いた部分配列を返します。取り除く要素がなければ nil を返します。

...

@param range 削除したい配列の範囲を Range オブジェクトで指定します。

//emlist[例][ruby]{
a = [ "a", "b", "c" ]
a.slice!(1, 2) #=> ["b", "c"]
a #=> ["a"]

a = [ "a", "b", "c" ]
a.slice!(1, 0) #=> []
a #=> [ "a", "b", "c" ]
//}...
<< 1 2 3 ... > >>