D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
String
/
Filename :
each_line-i.ri
back
Copy
U:RDoc::AnyMethod[iI"each_line:ETI"String#each_line;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"8With a block given, forms the substrings ("lines") ;TI"-that are the result of splitting +self+ ;TI"@at each occurrence of the given line separator +line_sep+; ;TI"$passes each line to the block; ;TI"returns +self+:;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"s = <<~EOT ;TI"This is the first line. ;TI"This is line two. ;TI" ;TI"This is line four. ;TI"This is line five. ;TI" EOT ;TI" ;TI""s.each_line {|line| p line } ;T:@format0o; ; [I"Output:;T@o;; [ I"!"This is the first line.\n" ;TI""This is line two.\n" ;TI" "\n" ;TI""This is line four.\n" ;TI""This is line five.\n" ;T; 0o; ; [I"!With a different +line_sep+:;T@o;; [I"*s.each_line(' is ') {|line| p line } ;T; 0o; ; [I"Output:;T@o;; [ I""This is " ;TI"!"the first line.\nThis is " ;TI""line two.\n\nThis is " ;TI""line four.\nThis is " ;TI""line five.\n" ;T; 0o; ; [I"LWith +chomp+ as +true+, removes the trailing +line_sep+ from each line:;T@o;; [I"/s.each_line(chomp: true) {|line| p line } ;T; 0o; ; [I"Output:;T@o;; [ I""This is the first line." ;TI""This is line two." ;TI""" ;TI""This is line four." ;TI""This is line five." ;T; 0o; ; [I")With an empty string as +line_sep+, ;TI"Cforms and passes "paragraphs" by splitting at each occurrence ;TI"of two or more newlines:;T@o;; [I"&s.each_line('') {|line| p line } ;T; 0o; ; [I"Output:;T@o;; [I"6"This is the first line.\nThis is line two.\n\n" ;TI"0"This is line four.\nThis is line five.\n" ;T; 0o; ; [I"0With no block given, returns an enumerator.;T: @fileI" string.c;T:0@omit_headings_from_table_of_contents_below0I"�each_line(line_sep = $/, chomp: false) {|substring| ... } -> self each_line(line_sep = $/, chomp: false) -> enumerator ;T0[ I"(*args);T@ZFI"String;TcRDoc::NormalClass00