443件ヒット
[1-100件を表示]
(0.030秒)
種類
- インスタンスメソッド (282)
- 文書 (77)
- モジュール関数 (48)
- 特異メソッド (24)
- ライブラリ (12)
モジュール
- JSON (24)
- Kernel (24)
-
OptionParser
:: Arguable (24) - Psych (12)
キーワード
- != (12)
- !~ (12)
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - === (12)
-
NEWS for Ruby 3
. 0 . 0 (5) - Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
- Rubyの起動 (12)
- clone (12)
-
dump
_ stream (12) - dup (12)
- fill (72)
-
instance
_ method (12) -
load
_ file! (12) - loop (24)
- parse! (12)
- raise (18)
-
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 4 feature (12) - slice! (36)
- uniq (24)
- uniq! (24)
- yaml (12)
-
yaml
_ tag (12) - クラス/メソッドの定義 (12)
検索結果
先頭5件
-
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" ]
//}...