るりまサーチ

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

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. t61string new
  4. matrix t
  5. fiddle type_size_t

ライブラリ

キーワード

検索結果

<< 1 2 3 > >>

Object#to_str -> String (6231.0)

オブジェクトの String への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。

...オブジェクトの String への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。

説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
...
...面で代置可能であるような、
* 文字列そのものとみなせるようなもの
という厳しいものになっています。

//emlist[][ruby]{
class Foo
def to_str
'Edition'
end
end

it = Foo.new
p('Second' + it) #=> "SecondEdition"
//}

@see Object#to_s,Kernel.#String...

Object#inspect -> String (6215.0)

オブジェクトを人間が読める形式に変換した文字列を返します。

...の結果を使用して
オブジェクトを表示します。

//emlist[][ruby]{
[ 1, 2, 3..4, 'five' ].inspect # => "[1, 2, 3..4, \"five\"]"
T
ime.new.inspect # => "2008-03-08 19:43:39 +0900"
//}

inspect メソッドをオーバーライドしなかった場合、クラス名...
...変数の名前、値の組を元にした文字列を返します。

//emlist[][ruby]{
class Foo
end
Foo.new.inspect # => "#<Foo:0x0300c868>"

class Bar
def initialize
@bar = 1
end
end
Bar.new.inspect # => "#<Bar:0x0300c868 @bar=1>"
//}

@see Kernel.#p...

Object#to_s -> String (6215.0)

オブジェクトの文字列表現を返します。

...rint や Kernel.#sprintf は文字列以外の
オブジェクトが引数に渡された場合このメソッドを使って文字列に変換し
ます。

//emlist[][ruby]{
class Foo
def initialize num
@num = num
end
end
it = Foo.new(40)

puts it #=> #<Foo:0x2b69110>

class Foo
def to_s...
..."Class:Foo Number:#{@num}"
end
end

puts it #=> Class:Foo Number:40
//}

@see Object#to_str,Kernel.#String...

Object#method(name) -> Method (6214.0)

オブジェクトのメソッド name をオブジェクト化した Method オブジェクトを返します。

...
Method オブジェクトを返します。

@param name メソッド名をSymbol またはStringで指定します。
@raise NameError 定義されていないメソッド名を引数として与えると発生します。

//emlist[][ruby]{
me = -365.method(:abs)
p me #=> #<Method: Integer#abs...
...>
p me.call #=> 365
//}

@see Module#instance_method, Method, BasicObject#__send__, Object#send, Kernel.#eval, Object#singleton_method...

Object#public_method(name) -> Method (6214.0)

オブジェクトの public メソッド name をオブジェクト化した Method オブジェクトを返します。

...thod オブジェクトを返します。

@param name メソッド名を Symbol または String で指定します。
@raise NameError 定義されていないメソッド名や、
protected メソッド名、 private メソッド名を引数として与えると発生します。

//emlist...
...[][ruby]{
1.public_method(:to_int) #=> #<Method: Integer#to_int>
1.public_method(:p) # method `p' for class `Integer' is private (NameError)
//}

@see Object#method,Object#public_send,Module#public_instance_method...

絞り込み条件を変える

Object#itself -> object (6138.0)

self を返します。

...self を返します。

//emlist[][ruby]{
string
= 'my string' # => "my string"
string
.itself.object_id == string.object_id # => true
//}...

Object#then -> Enumerator (6132.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}

値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。

//emlist[メソッドチェインのパイプライン][ruby]{
re...
...re 'json'

construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件に...
...あうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

Object#then {|x| ... } -> object (6132.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}

値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。

//emlist[メソッドチェインのパイプライン][ruby]{
re...
...re 'json'

construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件に...
...あうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

Object#tainted? -> bool (6126.0)

...オブジェクトの汚染に関してはspec/safelevelを参照してください。

//emlist[][ruby]{
p String.new.tainted? #=> false
p ENV['OS'].tainted? #=> true
//}

このメソッドは Ruby 2.7から deprecated で、Ruby 3.2 で削除予定です。

@see Object#taint,Object#untaint...

Object#singleton_class -> Class (6120.0)

レシーバの特異クラスを返します。 まだ特異クラスがなければ、新しく作成します。

...が nil か true か false なら、それぞれ NilClass, TrueClass,
FalseClass を返します。

@raise TypeError レシーバが Integer、Float、Symbol の場合に発生します。

//emlist[][ruby]{
Object
.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
String
.singleton_class #...
...=> #<Class:String>
nil.singleton_class #=> NilClass
//}

@see Object#class...

絞り込み条件を変える

<< 1 2 3 > >>