Class: DayOneKindle::Highlight

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Highlight

Returns a new instance of Highlight.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/dayone-kindle/highlight.rb', line 5

def initialize(options)
  # Faking required named arguments for ruby 2.0 compatibility
  %i(book highlight time).each do |param|
    raise ArgumentError, "missing keyword :#{param}" unless options[param]
    instance_variable_set(:"@#{param}", options[param])
  end

  @page = options[:page]
  @location = options[:location]
  @authors = options[:authors] || []
end

Instance Attribute Details

#authorsObject (readonly)

Returns the value of attribute authors.



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

def authors
  @authors
end

#bookObject (readonly)

Returns the value of attribute book.



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

def book
  @book
end

#highlightObject (readonly)

Returns the value of attribute highlight.



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

def highlight
  @highlight
end

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#pageObject (readonly)

Returns the value of attribute page.



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

def page
  @page
end

#timeObject (readonly)

Returns the value of attribute time.



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

def time
  @time
end

Instance Method Details

#to_markdownObject



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

def to_markdown
  [
    markdown_header,
    '',
    markdown_authors,
    '',
    markdown_highlight,
    '',
    markdown_meta
  ].compact.join("\n")
end