Method: Cane::EncodingAwareIterator#each

Defined in:
lib/cane/encoding_aware_iterator.rb

#each(&block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cane/encoding_aware_iterator.rb', line 11

def each(&block)
  return self.to_enum unless block

  lines.each do |line|
    begin
      line =~ /\s/
    rescue ArgumentError
      line.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace)
    end

    block.call(line)
  end
end