Module: ARGF

### Home Classes Methods

### In Files

- lib/backports/1.8.7/argf/each_byte.rb
- lib/backports/1.8.7/argf/each_char.rb
- lib/backports/1.8.7/argf/getbyte.rb
- lib/backports/1.8.7/argf/lines.rb
- lib/backports/1.8.7/argf/readbyte.rb

### Methods

- ::each_char

### Class/Module Index

Quicksearch

- Prime
- Prime::EratosthenesGenerator
- Prime::EratosthenesSieve
- Prime::Generator23
- Prime::OldCompatibility
- Prime::PseudoPrimeGenerator
- Prime::TrialDivision
- Prime::TrialDivisionGenerator
- Backports
- Backports::MOST_EXTREME_OBJECT_EVER
- Backports::StdLib
- Backports::StdLib::LoadedFeatures
- Enumerator
- Enumerator::GeneratorBP
- Enumerator::Lazy
- Enumerator::Yielder
- Matrix
- Matrix::EigenvalueDecomposition
- Matrix::LUPDecomposition
- Random
- Random::Implementation
- Random::MT19937
- Enumerable
- Enumerable::Enumerator
- File
- File::Constants
- ARGF
- Array
- BasicObject
- Binding
- Complex
- Dir
- ENV
- Fixnum
- Float
- GC
- Hash
- IO
- Integer
- Kernel
- Math
- Method
- Module
- NilClass
- Numeric
- Object
- ObjectSpace
- OpenStruct
- Proc
- Process
- Range
- Regexp
- Set
- StopIteration
- String
- Struct
- Symbol
- UnboundMethod

No matching classes.

# ARGF

### Public Class Methods

each_char() click to toggle source

    # File lib/backports/1.8.7/argf/each_char.rb, line 6
    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

[Validate]

Generated with the Darkfish Rdoc Generator 2.