Class: KindleClippings::Parser
- Inherits:
-
Object
- Object
- KindleClippings::Parser
- Defined in:
- lib/kindleclippings.rb
Instance Method Summary collapse
Instance Method Details
#parse(filecontent) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/kindleclippings.rb', line 20 def parse(filecontent) @clippings = ClippingResult.new filecontent.split("=" * 10).each do |clipping| a_clipping = parse_clipping(clipping) if a_clipping @clippings << a_clipping end end @clippings end |
#parse_file(path) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/kindleclippings.rb', line 7 def parse_file(path) file_content = String.new if RUBY_VERSION =~ /^1\.8/ file_content = open(path).read else file_content = File.open(path, :encoding => "UTF-8").read end parse(file_content) end |