るりまサーチ

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

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. rubygems/custom_require require
  4. irb/ext/use-loader irb_require
  5. require execute

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

CSV::FieldInfo#line -> Integer (18114.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 "da...

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

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

...[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) -> Enumerator (6218.0)

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

...[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...

WEBrick::HTTPResponse#status_line -> String (6114.0)

HTTP のステータスラインを CR+LF 付き文字列で返します。

...HTTP のステータスラインを CR+LF 付き文字列で返します。

require
'webrick'
res = WEBrick::HTTPResponse.new( { :HTTPVersion => "1.1" } )
res.status = 404

p res.status_line #=> "HTTP/1.1 404 Not Found \r\n"...

StringScanner#beginning_of_line? -> bool (6108.0)

スキャンポインタが行頭を指しているなら 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? # => tru...

絞り込み条件を変える

CSV#lineno -> Integer (6107.0)

このファイルから読み込んだ最終行の行番号を返します。 フィールドに含まれる改行はこの値には影響しません。

...このファイルから読み込んだ最終行の行番号を返します。
フィールドに含まれる改行はこの値には影響しません。

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

csv = CSV.new("header1,header2\nrow1_1,row1_2")
csv.lineno # => 0
csv.readline
csv.lineno # => 1
//}...

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

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

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

例1:irb で実行した場合

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

例2:

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

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

StringIO#readline(rs = $/) -> String (6107.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 が発生する
//}

@see...

StringIO#readlines(rs = $/) -> [String] (6107.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 $/...
<< 1 2 3 ... > >>