るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

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

行番号を返します。

...

//emlist[例][ruby]{
require
'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>, ...]
//}...

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

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

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

例1:irb で実行した場合

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

例2:

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

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

Pathname#each_line(*args) -> Enumerator (9342.0)

IO.foreach(self.to_s, *args, &block) と同じです。

...f.to_s, *args, &block) と同じです。

//emlist[例][ruby]{
require
"pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line
# => #<Enumerator: IO:foreach("testfile")>
//}

//emlist[例 ブロックを指定][ruby]{
require
"pathname"

IO.write("testfile", "line1...
...\nline2,\nline3\n")
Pathname("testfile").each_line {|f| p f }

# => "line1\n"
# => "line2,\n"
# => "line3\n"
//}

//emlist[例 limit を指定][ruby]{
require
"pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(4) {|f| p f }

# => "line"
# => "1\n"
# => "line"
#...
...=> "2,\n"
# => "line"
# => "3\n"
//}

//emlist[例 sep を指定][ruby]{
require
"pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(",") {|f| p f }

# => "line1\nline2,"
# => "\nline3\n"
//}

@see IO.foreach...

Pathname#each_line(*args) {|line| ... } -> nil (9342.0)

IO.foreach(self.to_s, *args, &block) と同じです。

...f.to_s, *args, &block) と同じです。

//emlist[例][ruby]{
require
"pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line
# => #<Enumerator: IO:foreach("testfile")>
//}

//emlist[例 ブロックを指定][ruby]{
require
"pathname"

IO.write("testfile", "line1...
...\nline2,\nline3\n")
Pathname("testfile").each_line {|f| p f }

# => "line1\n"
# => "line2,\n"
# => "line3\n"
//}

//emlist[例 limit を指定][ruby]{
require
"pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(4) {|f| p f }

# => "line"
# => "1\n"
# => "line"
#...
...=> "2,\n"
# => "line"
# => "3\n"
//}

//emlist[例 sep を指定][ruby]{
require
"pathname"

IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(",") {|f| p f }

# => "line1\nline2,"
# => "\nline3\n"
//}

@see IO.foreach...

StringIO#readline(rs = $/) -> String (9213.0)

自身から 1 行読み込んで、その文字列を返します。

...読み込んで、その文字列を返します。

文字列の終端に到達した時には、例外 EOFError を発生させます。
IO#readline と違い読み込んだ文字列を変数 $_ にセットしません。

@param rs 行の区切りを文字列で指定します。rs に nil を...
...プンされていなければ発生します。

//emlist[例][ruby]{
require
"stringio"
a = StringIO.new("hoge\nfoo\nbar\n")
a.readline #=> "hoge\n"
a.readline(nil) #=> "foo\nbar\n"
a.readline #=> EOFError が発生する
//}...

絞り込み条件を変える

StringIO#readlines(rs = $/) -> [String] (9213.0)

自身からデータを全て読み込んで、その各行を要素としてもつ配列を返します。 既に文字列の終端に達していれば空配列 [] を返します。

...ise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例][ruby]{
require
"stringio"
a = StringIO.new("hoge\nfoo\nbar\n")
a.readlines #=> ["hoge\n", "foo\n", "bar\n"]
a.readlines #=> []
//}

@see $/...

StringScanner#beginning_of_line? -> bool (9114.0)

スキャンポインタが行頭を指しているなら true を、 行頭以外を指しているなら false を返します。

... true を、
行頭以外を指しているなら false を返します。

行頭の定義は、文字列先頭かまたは \n の直後を指していることです。
文字列末尾は必ずしも行頭ではありません。

//emlist[例][ruby]{
require
'strscan'

s = StringScanner.new("test...
...\nstring")
s.bol? # => true
s.scan(/\w+/)
s.bol? # => false
s.scan(/\n/)
s.bol? # => true
s.scan(/\w+/)
s.bol? # => false
//}...

StringIO#each_line(rs = $/) -> Enumerator (6224.0)

自身から 1 行ずつ読み込み、それを引数として与えられたブロックを実行します。

...連続する改行を行の区切りとみなします(パラグラフモード)。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
require
"stringio"
a = StringIO.new("hoge\nfoo\n")
a.each{|l| p l }
#=> "hoge\n"
# "foo\n"
//}

@see $/
@see IO#each_line...

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

自身から 1 行ずつ読み込み、それを引数として与えられたブロックを実行します。

...連続する改行を行の区切りとみなします(パラグラフモード)。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
require
"stringio"
a = StringIO.new("hoge\nfoo\n")
a.each{|l| p l }
#=> "hoge\n"
# "foo\n"
//}

@see $/
@see IO#each_line...

StringIO#lines(rs = $/) -> Enumerator (6224.0)

自身から 1 行ずつ読み込み、それを引数として与えられたブロックを実行します。

...連続する改行を行の区切りとみなします(パラグラフモード)。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
require
"stringio"
a = StringIO.new("hoge\nfoo\n")
a.each{|l| p l }
#=> "hoge\n"
# "foo\n"
//}

@see $/
@see IO#each_line...

絞り込み条件を変える

<< 1 2 3 ... > >>