るりまサーチ

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

別のキーワード

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

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

RubyVM::InstructionSequence#first_lineno -> Integer (24307.0)

self が表す命令シーケンスの 1 行目の行番号を返します。

...の 1 行目の行番号を返します。

例1:irb で実行した場合

Ruby
VM::InstructionSequence.compile('num = 1 + 2').first_lineno
# => 1

例2:

# /tmp/method.rb
r
equire "foo-library"
def foo
p :foo
end


Ruby
VM::InstructionSequence.of(method(:foo)).first_lineno
# => 2...

CSV::FieldInfo#line -> Integer (18320.0)

行番号を返します。

...

//emlist[例][ruby]{
r
equire 'csv'

csv = CSV.new("date1,date2,date3\n2018-07-09,2018-07-10\n2018-08-09,2018-08-10", headers: true)
csv.convert do |field,field_info|
p field_info.line
Date.parse(field)
end

p csv.to_a

# => 2
# => 2
# => 3
# => 3
# => [#<CSV::Row "date1":#<Date: 2018-07-09 (...
...(2458309j,0s,0n),+0s,2299161j)> "date2":#<Date: 2018-07-10 ((2458310j,0s,0n),+0s,2299161j)> "date3":nil>, ...]
//}...

Enumerator::Yielder#to_proc -> Proc (15349.0)

Enumerator.new で使うメソッドです。

...Enumerator.new で使うメソッドです。

引数を Enumerator::Yielder#yield に渡す Proc を返します。
これは Enumerator::Yielder オブジェクトを他のメソッドにブロック引数と
して直接渡すために使えます。

//emlist[例][ruby]{
t
ext = <<-END
Hello
...
...んにちは
END


enum = Enumerator.new do |y|
t
ext.each_line(&y)
end


enum.each do |line|
p line
end

# => "Hello\n"
# "こんにちは\n"
//}...

IRB::ExtendCommand::Help#execute(*names) -> nil (15129.0)

RI から Ruby のドキュメントを参照します。

...
R
I から Ruby のドキュメントを参照します。

irb(main):001:0> help String#match
...

@param names 参照したいクラス名やメソッド名などを文字列で指定します。

names を指定しなかった場合は、RI を対話的なモードで起動します。メソ...
...空行を入力する事で irb のプロンプトに戻る事ができま
す。

irb(main):001:0> help

Enter the method name you want to look up.
You can use tab to autocomplete.
Enter a blank line to exit.

>> String#match
String#match

(from ruby core)
--------------------------...
...----------------------------------------------------
str.match(pattern) -> matchdata or nil
str.match(pattern, pos) -> matchdata or nil
......

String#each_line(rs = $/) -> Enumerator (12350.0)

文字列中の各行に対して繰り返します。 行の区切りは rs に指定した文字列で、 そのデフォルト値は変数 $/ の値です。 各 line には区切りの文字列も含みます。

...て繰り返します。
行の区切りは rs に指定した文字列で、
そのデフォルト値は変数 $/ の値です。
line には区切りの文字列も含みます。

r
s に nil を指定すると行区切りなしとみなします。
r
s に空文字列 "" を指定すると「...
...ます)。

@param rs 行末を示す文字列

//emlist[例][ruby]{
"aa\nbb\ncc\n".each_line do |line|
p line
end

# => "aa\n"
# => "bb\n"
# => "cc\n"

p "aa\nbb\ncc\n".lines.to_a # => ["aa\n", "bb\n", "cc\n"]
p "aa\n".lines.to_a # => ["aa\n"]
p "".lines.to_a...
...# => []

s = "aa\nbb\ncc\n"
p s.lines("\n").to_a #=> ["aa\n", "bb\n", "cc\n"]
p s.lines("bb").to_a #=> ["aa\nbb", "\ncc\n"]
//}

@see String#lines...

絞り込み条件を変える

String#each_line(rs = $/) {|line| ... } -> self (12350.0)

文字列中の各行に対して繰り返します。 行の区切りは rs に指定した文字列で、 そのデフォルト値は変数 $/ の値です。 各 line には区切りの文字列も含みます。

...て繰り返します。
行の区切りは rs に指定した文字列で、
そのデフォルト値は変数 $/ の値です。
line には区切りの文字列も含みます。

r
s に nil を指定すると行区切りなしとみなします。
r
s に空文字列 "" を指定すると「...
...ます)。

@param rs 行末を示す文字列

//emlist[例][ruby]{
"aa\nbb\ncc\n".each_line do |line|
p line
end

# => "aa\n"
# => "bb\n"
# => "cc\n"

p "aa\nbb\ncc\n".lines.to_a # => ["aa\n", "bb\n", "cc\n"]
p "aa\n".lines.to_a # => ["aa\n"]
p "".lines.to_a...
...# => []

s = "aa\nbb\ncc\n"
p s.lines("\n").to_a #=> ["aa\n", "bb\n", "cc\n"]
p s.lines("bb").to_a #=> ["aa\nbb", "\ncc\n"]
//}

@see String#lines...

String#each_line(rs = $/, chomp: false) -> Enumerator (12350.0)

文字列中の各行に対して繰り返します。 行の区切りは rs に指定した文字列で、 そのデフォルト値は変数 $/ の値です。 各 line には区切りの文字列も含みます。

...て繰り返します。
行の区切りは rs に指定した文字列で、
そのデフォルト値は変数 $/ の値です。
line には区切りの文字列も含みます。

r
s に nil を指定すると行区切りなしとみなします。
r
s に空文字列 "" を指定すると「...
...します)。

@param rs 行末を示す文字列
@param chomp true を指定すると各行の末尾から rs を取り除きます。

//emlist[例][ruby]{
"aa\nbb\ncc\n".each_line do |line|
p line
end

# => "aa\n"
# => "bb\n"
# => "cc\n"

p "aa\nbb\ncc\n".lines.to_a # => ["aa\n"...
..., "bb\n", "cc\n"]
p "aa\n".lines.to_a # => ["aa\n"]
p "".lines.to_a # => []

s = "aa\nbb\ncc\n"
p s.lines("\n").to_a #=> ["aa\n", "bb\n", "cc\n"]
p s.lines("bb").to_a #=> ["aa\nbb", "\ncc\n"]
//}

@see String#lines...

String#each_line(rs = $/, chomp: false) {|line| ... } -> self (12350.0)

文字列中の各行に対して繰り返します。 行の区切りは rs に指定した文字列で、 そのデフォルト値は変数 $/ の値です。 各 line には区切りの文字列も含みます。

...て繰り返します。
行の区切りは rs に指定した文字列で、
そのデフォルト値は変数 $/ の値です。
line には区切りの文字列も含みます。

r
s に nil を指定すると行区切りなしとみなします。
r
s に空文字列 "" を指定すると「...
...します)。

@param rs 行末を示す文字列
@param chomp true を指定すると各行の末尾から rs を取り除きます。

//emlist[例][ruby]{
"aa\nbb\ncc\n".each_line do |line|
p line
end

# => "aa\n"
# => "bb\n"
# => "cc\n"

p "aa\nbb\ncc\n".lines.to_a # => ["aa\n"...
..., "bb\n", "cc\n"]
p "aa\n".lines.to_a # => ["aa\n"]
p "".lines.to_a # => []

s = "aa\nbb\ncc\n"
p s.lines("\n").to_a #=> ["aa\n", "bb\n", "cc\n"]
p s.lines("bb").to_a #=> ["aa\nbb", "\ncc\n"]
//}

@see String#lines...

TracePoint#lineno -> Integer (12319.0)

発生したイベントの行番号を返します。

...発生したイベントの行番号を返します。

@raise RuntimeError イベントフックの外側で実行した場合に発生します。

//emlist[例][ruby]{
def foo(ret)
r
et
end

t
race = TracePoint.new(:call, :return) do |tp|
t
p.lineno
end

t
race.enable
foo 1
# => 1
# 3
//}...

Module#const_source_location(name, inherited = true) -> [String, Integer] (12249.0)

name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。

...す。

@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義された定数が対象にはなります。false を指定した場合 対象にはなりません。
@return ソース...
...st[例][ruby]{
# test.rb:
class A # line 1
C1 = 1
C2 = 2
end


module M # line 6
C3 = 3
end


class B < A # line 10
include M
C4 = 4
end


class A # 継続して A を定義する
C2 = 8 # 定数を再定義する
end


p B.const_source_location('C4') # => ["test...
....rb", 12]
p B.const_source_location('C3') # => ["test.rb", 7]
p B.const_source_location('C1') # => ["test.rb", 2]

p B.const_source_location('C3', false) # => nil -- include したモジュールは検索しない

p A.const_source_location('C2') # => ["test.rb", 16...

絞り込み条件を変える

Thread#set_trace_func(pr) -> Proc | nil (12243.0)

スレッドにトレース用ハンドラを設定します。

...

//emlist[例][ruby]{
t
h = Thread.new do
class Trace
end

2.to_s
T
hread.current.set_trace_func nil
3.to_s
end

t
h.set_trace_func lambda {|*arg| p arg }
t
h.join

# => ["line", "example.rb", 2, nil, #<Binding:0x00007fc8de87cb08>, nil]
# => ["c-call", "example.rb", 2, :inherited, #<Binding:...
...8de886770>, Class]
# => ["c-return", "example.rb", 2, :inherited, #<Binding:0x00007fc8de8844e8>, Class]
# => ["class", "example.rb", 2, nil, #<Binding:0x00007fc8de88e830>, nil]
# => ["end", "example.rb", 3, nil, #<Binding:0x00007fc8de88d6b0>, nil]
# => ["line", "example.rb", 4, nil, #<Binding:0x0000...
...xample.rb", 4, :to_s, #<Binding:0x00007fc8de896f30>, Integer]
# => ["c-return", "example.rb", 4, :to_s, #<Binding:0x00007fc8de894a50>, Integer]
# => ["line", "example.rb", 5, nil, #<Binding:0x00007fc8de967b08>, nil]
# => ["c-call", "example.rb", 5, :current, #<Binding:0x00007fc8de967798>, Thread]
#...
<< 1 2 3 ... > >>