Class: ARGF
Instance Method Summary collapse
-
#bytes ⇒ Object
No official documentation…
-
#chars ⇒ Object
No official documentation…
-
#each_char ⇒ Object
No official documentation…
-
#lines(*args) ⇒ Object
No official documentation…
Instance Method Details
#bytes ⇒ Object
No official documentation…
10 11 12 |
# File 'lib/backports/1.8.7/argf.rb', line 10 def bytes to_enum :each_byte end |
#chars ⇒ Object
No official documentation…
15 16 17 |
# File 'lib/backports/1.8.7/argf.rb', line 15 def chars to_enum :each_char end |
#each_char ⇒ Object
No official documentation…
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/backports/1.8.7/argf.rb', line 20 def each_char return to_enum(:each_char) unless block_given? if $KCODE == "UTF-8" lookup = 7.downto(4) while c = read(1) do n = c[0] leftmost_zero_bit = lookup.find{|i| n[i].zero? } case leftmost_zero_bit when 7 # ASCII yield c when 6 # UTF 8 complementary characters next # Encoding error, ignore else more = read(6-leftmost_zero_bit) break unless more yield c+more end end else while s = read(1) yield s end end self end |
#lines(*args) ⇒ Object
No official documentation…
54 55 56 |
# File 'lib/backports/1.8.7/argf.rb', line 54 def lines(*args) to_enum :each_line, *args end |