Class: Fyodor::ClippingsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/fyodor/clippings_parser.rb

Constant Summary collapse

SEPARATOR =
/^==========\r?\n$/

Instance Method Summary collapse

Constructor Details

#initialize(clippings_path, parser_config) ⇒ ClippingsParser

Returns a new instance of ClippingsParser.



7
8
9
10
# File 'lib/fyodor/clippings_parser.rb', line 7

def initialize(clippings_path, parser_config)
  @path = clippings_path
  @config = parser_config
end

Instance Method Details

#parse(library) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fyodor/clippings_parser.rb', line 12

def parse(library)
  lines = []
  File.open(@path).each do |line|
    lines << line
    if end_entry?(lines)
      library << parse_entry(lines)
      lines.clear
    end
  end
  raise "MyClippings is badly formatted" if lines.size > 0
end