Class: TwitterCldr::Resources::UnicodeFileParser

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_cldr/resources/unicode_file_parser.rb

Class Method Summary collapse

Class Method Details

.parse_standard_file(file) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/twitter_cldr/resources/unicode_file_parser.rb', line 11

def parse_standard_file(file)
  if block_given?
    File.open(file) do |input|
      input.each_line do |line|
        unless line[0] == '#'
          comment_idx = if idx = line.index('#')
            idx - 1 # consume #
          else
            line.size
          end

          line = line.chomp[0..comment_idx]
          if line.size > 0
            yield line.split(';', -1).map(&:strip)
          end
        end
      end
    end
  else
    enum_for(__method__, file)
  end
end