るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin each

ライブラリ

クラス

モジュール

オブジェクト

キーワード

検索結果

<< < ... 5 6 7 8 9 ... > >>

Range.new(first, last, exclude_end = false) -> Range (8012.0)

first から last までの範囲オブジェクトを生成して返しま す。

...のオブジェクトの場合][ruby]{
MyInteger = Struct.new(:value) do
def succ
self.class.new(value + 1)
end

def <=>(other)
value <=> other.value
end

def to_s
value.to_s
end
end
Range.new(MyInteger.new(1), MyInteger.new(3)).each {|i| puts i }
# => 1
# 2
# 3
//}...

String#intern -> Symbol (8012.0)

文字列に対応するシンボル値 Symbol を返します。

...応する文字列を得るには
Symbol#to_s または Symbol#id2name を使います。

シンボル文字列にはヌルキャラクタ("\0")、空の文字列の使用も可能です。

//emlist[例][ruby]{
p "foo".intern # => :foo
p "foo".intern.to_s == "foo" # => true
//}...

Symbol.all_symbols -> [Symbol] (8012.0)

定義済みの全てのシンボルオブジェクトの配列を返します。

...nd

p Symbol.all_symbols.select{|sym|sym.to_s.include? 'make'}
#=> [:make_1, :make_2]

re = #確実に生成されるように代入操作を行う
:make_1,
:'make_2',
:"#{number}",
'make_4'.intern

p Symbol.all_symbols.select{|sym|sym.to_s.include? 'make'}
#=> [:make_1, :make_2,...

Thread::Backtrace::Location (8012.0)

Ruby のフレームを表すクラスです。

...caller_locations.rb
def a(skip)
caller_locations(skip)
end
def b(skip)
a(skip)
end
def c(skip)
b(skip)
end

c(0..2).map do |call|
puts call.to_s
end
//}

例1の実行結果:

caller_locations.rb:2:in `a'
caller_locations.rb:5:in `b'
caller_locations.rb:8:in `c'

//emlist[例2][ruby]{...
...ttr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end

Foo.new(0..2).locations.map do |call|
puts call.to_s
end
//}

例2の実行結果:

init.rb:4:in `initialize'
init.rb:8:in `new'
init.rb:8:in `<main>'

=== 参考

* Ruby VM アドベントカ...

Symbol#[](nth) -> String | nil (8010.0)

nth 番目の文字を返します。

...nth 番目の文字を返します。

(self.to_s[nth] と同じです。)

@param nth 文字の位置を表す整数を指定します。

:foo[0] # => "f"
:foo[1] # => "o"
:foo[2] # => "o"...

絞り込み条件を変える

Symbol#[](nth, len) -> String | nil (8010.0)

nth 番目から長さ len の部分文字列を新しく作って返します。

...nth 番目から長さ len の部分文字列を新しく作って返します。

(self.to_s[nth, len] と同じです。)

@param nth 文字の位置を表す整数を指定します。
@param len 文字列の長さを指定します。

:foo[1, 2] # => "oo"...

Symbol#[](range) -> String | nil (8010.0)

rangeで指定したインデックスの範囲に含まれる部分文字列を返します。

...rangeで指定したインデックスの範囲に含まれる部分文字列を返します。

(self.to_s[range] と同じです。)

@param range 取得したい文字列の範囲を示す Range オブジェクトを指定します。

:foo[0..1] # => "fo"

@see String#[] , String#slice...

Symbol#[](regexp, nth = 0) -> String | nil (8010.0)

正規表現 regexp の nth 番目の括弧にマッチする最初の部分文字列を返します。

...正規表現 regexp の nth 番目の括弧にマッチする最初の部分文字列を返します。

(self.to_s[regexp, nth] と同じです。)

@param regexp 正規表現を指定します。

@param nth 取得したい正規表現レジスタのインデックスを指定します。

:foo...

Symbol#[](substr) -> String | nil (8010.0)

self が substr を含む場合、一致した文字列を新しく作って返します。

...self が substr を含む場合、一致した文字列を新しく作って返します。

(self.to_s[substr] と同じです。)

例:
:foobar.slice("foo") # => "foo"
:foobar.slice("baz") # => nil...

Symbol#slice(nth) -> String | nil (8010.0)

nth 番目の文字を返します。

...nth 番目の文字を返します。

(self.to_s[nth] と同じです。)

@param nth 文字の位置を表す整数を指定します。

:foo[0] # => "f"
:foo[1] # => "o"
:foo[2] # => "o"...

絞り込み条件を変える

<< < ... 5 6 7 8 9 ... > >>