Class: Evertils::Helper::EvernoteENML

Inherits:
Object
  • Object
show all
Defined in:
lib/evertils/helpers/evernote-enml.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = nil) ⇒ EvernoteENML

TODO: refactor this whole class so you can create ENML elements with it



7
8
9
10
11
12
13
14
# File 'lib/evertils/helpers/evernote-enml.rb', line 7

def initialize(file = nil)
  @file = file
  @element = enml_element

  if !@element.nil?
    @embeddable_element = "<hr/>Attachment with hash #{@element.data.bodyHash}<br /><en-media type=\"#{@element.mime}\" hash=\"#{@element.data.bodyHash}\" /><br /><br />"
  end
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



4
5
6
# File 'lib/evertils/helpers/evernote-enml.rb', line 4

def element
  @element
end

#embeddable_elementObject (readonly)

Returns the value of attribute embeddable_element.



4
5
6
# File 'lib/evertils/helpers/evernote-enml.rb', line 4

def embeddable_element
  @embeddable_element
end

Class Method Details

.with_list(arr) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/evertils/helpers/evernote-enml.rb', line 16

def self.with_list(arr)
  enml_bucket = []

  if arr.respond_to? :each_pair
    arr.each_pair do |title, data|
      enml_bucket.push("<br /><div><span style=\"font-size: 18px;\">#{title}</span></div>")

      enml_bucket.push('<ul>')

      data.each do |item|
        enml_bucket.push("<li>#{item}</li>")
      end

      enml_bucket.push('</ul>')
    end

    enml_bucket.join
  end
end