Class: Klipbook::Sources::KindleDevice::EntryParser

Inherits:
Object
  • Object
show all
Defined in:
lib/klipbook/sources/kindle_device/entry_parser.rb

Instance Method Summary collapse

Instance Method Details

#build_entry(entry_text) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/klipbook/sources/kindle_device/entry_parser.rb', line 5

def build_entry(entry_text)
  return nil if invalid_entry?(entry_text)

  lines = split_text_into_lines(entry_text)
  title_line = lines[0].strip
   = lines[1].strip
  text_lines = lines[3..-1]

  type = extract_type()

  Klipbook::Sources::KindleDevice::Entry.new do |h|
    h.title = extract_title(title_line)
    h.author = extract_author(title_line)
    h.location = extract_location()
    h.page = extract_page()
    h.added_on = extract_added_date()
    h.text = extract_content(text_lines)
    h.type = extract_type()
  end
end