クラス
-
ARGF
. class (24) - IO (168)
- String (90)
モジュール
- Enumerable (22)
検索結果
先頭5件
-
String
# chomp(rs = $ / ) -> String (18176.0) -
self の末尾から rs で指定する改行コードを取り除いた文字列を生成して返します。 ただし、rs が "\n" ($/ のデフォルト値) のときは、 実行環境によらず "\r", "\r\n", "\n" のすべてを改行コードとみなして取り除きます。
...o\n".chomp # => "foo"
p "foo\n".chomp("\n") # => "foo"
p "foo\r\n".chomp("\r\n") # => "foo"
$/ = "\n" # デフォルト値と同じ
p "foo\r".chomp # => "foo"
p "foo\r\n".chomp # => "foo"
p "foo\n".chomp # => "foo"
p "foo\n\r".chomp # => "foo\n"
p "string\n".chomp(nil......) # => "string\n"
p "foo\r\n\n".chomp("") # => "foo"
p "foo\n\r\n".chomp("") # => "foo"
p "foo\n\r\r".chomp("") # => "foo\n\r\r"
//}
@see String#chomp!
@see String#chop......) # => "string\n"
p "foo\r\n\n".chomp("") # => "foo"
p "foo\n\r\n".chomp("") # => "foo"
p "foo\n\r\r".chomp("") # => "foo\n\r\r"
//}
@see String#chomp!
@see String#chop
@see String#delete_suffix... -
String
# chomp!(rs = $ / ) -> self | nil (6170.0) -
self の末尾から rs で指定する改行コードを取り除きます。 ただし rs が "\n" ($/ のデフォルト値) のときは、 実行環境によらず "\r", "\r\n", "\n" のすべてを改行コードとみなして取り除きます。
...@return chomp! は通常 self を返しますが、取り除く改行がなかった場合は nil を返します。
//emlist[例][ruby]{
buf = "string\n"
buf.chomp! # => nil
p buf # => "string"
$/ = "\n" # デフォルトと同じ
p "foo\r".chomp! # => "foo"
p "foo\r\n".chomp! # =>......"foo"
p "foo\n".chomp! # => "foo"
p "foo\n\r".chomp! # => "foo\n"
buf = "string\n"
buf.chomp!(nil) # => nil
p buf # => "string\n"
p "foo\r\n\n".chomp!("") # => "foo"
p "foo\n\r\n".chomp!("") # => "foo"
p "foo\n\r\r".chomp!("") # => nil
//}
@see String#chomp
@see String#chop!......"foo"
p "foo\n".chomp! # => "foo"
p "foo\n\r".chomp! # => "foo\n"
buf = "string\n"
buf.chomp!(nil) # => nil
p buf # => "string\n"
p "foo\r\n\n".chomp!("") # => "foo"
p "foo\n\r\n".chomp!("") # => "foo"
p "foo\n\r\r".chomp!("") # => nil
//}
@see String#chomp
@see String#chop!
@s... -
IO
# each(limit , chomp: false) -> Enumerator (133.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...すると連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。
@raise IOError 自身が読み込み用にオ......This is li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "... -
IO
# each(limit , chomp: false) {|line| . . . } -> self (133.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...すると連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。
@raise IOError 自身が読み込み用にオ......This is li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "... -
IO
# each(rs = $ / , chomp: false) -> Enumerator (133.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...すると連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。
@raise IOError 自身が読み込み用にオ......This is li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "... -
IO
# each(rs = $ / , chomp: false) {|line| . . . } -> self (133.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...すると連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。
@raise IOError 自身が読み込み用にオ......This is li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "... -
IO
# each(rs , limit , chomp: false) -> Enumerator (133.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...すると連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。
@raise IOError 自身が読み込み用にオ......This is li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "... -
IO
# each(rs , limit , chomp: false) {|line| . . . } -> self (133.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...すると連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。
@raise IOError 自身が読み込み用にオ......This is li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "... -
IO
# each _ line(limit , chomp: false) -> Enumerator (133.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...すると連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。
@raise IOError 自身が読み込み用にオ......This is li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "... -
IO
# each _ line(limit , chomp: false) {|line| . . . } -> self (133.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...すると連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。
@raise IOError 自身が読み込み用にオ......This is li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "... -
IO
# each _ line(rs = $ / , chomp: false) -> Enumerator (133.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...すると連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。
@raise IOError 自身が読み込み用にオ......This is li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "... -
IO
# each _ line(rs = $ / , chomp: false) {|line| . . . } -> self (133.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...すると連続する改行を行の区切りとみなします(パラグラフモード)。
@param limit 最大の読み込みバイト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。
@raise IOError 自身が読み込み用にオ......This is li"
# "3: ne three,"
# "3: And so on."
# "4: .."
//}
//emlist[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "...