Class: DayOneKindle::ClippingParser

Inherits:
Object
  • Object
show all
Defined in:
lib/dayone-kindle/clipping_parser.rb

Constant Summary collapse

REGEX =
%r{^
  (?<book>.+)\s\((?<authors>.+)\)\n
  \-\s(?<metadata>.+)\n\n
  (?<quote>.+)?
$}xi

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ ClippingParser

Returns a new instance of ClippingParser.



11
12
13
# File 'lib/dayone-kindle/clipping_parser.rb', line 11

def initialize(raw)
  @raw = raw
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



3
4
5
# File 'lib/dayone-kindle/clipping_parser.rb', line 3

def raw
  @raw
end

Instance Method Details

#highlightObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dayone-kindle/clipping_parser.rb', line 15

def highlight
  return unless .match(/Highlight/i)
  return unless quote

  Highlight.new(
    book: book,
    highlight: quote,
    time: time,
    page: page,
    location: location,
    authors: authors
  )
end