440件ヒット
[1-100件を表示]
(0.079秒)
別のキーワード
ライブラリ
- ビルトイン (12)
- csv (120)
- optparse (24)
- pathname (36)
-
shell
/ filter (6) - stringio (86)
- strscan (24)
-
webrick
/ httpresponse (12) - zlib (120)
クラス
- Array (12)
- CSV (84)
-
CSV
:: FieldInfo (12) - OptionParser (24)
- Pathname (36)
-
RubyVM
:: InstructionSequence (12) -
Shell
:: Filter (6) - String (12)
- StringIO (86)
- StringScanner (24)
-
WEBrick
:: HTTPResponse (12) -
Zlib
:: GzipReader (120)
キーワード
-
beginning
_ of _ line? (12) - binread (12)
- bol? (12)
- convert (36)
- each (54)
-
each
_ line (72) - eof (12)
- eof? (12)
-
field
_ size _ limit (12) -
first
_ lineno (12) - lineno (24)
- lineno= (12)
- lines (14)
-
parse
_ csv (12) - readline (36)
- readlines (36)
-
status
_ line (12) - summarize (24)
-
to
_ csv (12)
検索結果
先頭5件
-
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 $/...