Class: Karasuba::Note

Inherits:
Object
  • Object
show all
Defined in:
lib/karasuba/note.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml, options = {}) ⇒ Note

Returns a new instance of Note.



5
6
7
8
9
10
11
# File 'lib/karasuba/note.rb', line 5

def initialize(xml, options = {})
  @xml            = xml
  @options        = options
  @todos          = []
  @todo_elements  = xml.xpath('//en-todo')
  instanciate_todos
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/karasuba/note.rb', line 3

def options
  @options
end

#todosObject (readonly)

Returns the value of attribute todos.



3
4
5
# File 'lib/karasuba/note.rb', line 3

def todos
  @todos
end

#xmlObject (readonly)

Returns the value of attribute xml.



3
4
5
# File 'lib/karasuba/note.rb', line 3

def xml
  @xml
end

Instance Method Details



13
14
15
16
# File 'lib/karasuba/note.rb', line 13

def append_footer(text, options = {})
  appender = FooterAppender.new(append_footer_point)
  appender.append_footer(text, options)
end

#equivalent?(doc_or_string) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/karasuba/note.rb', line 18

def equivalent?(doc_or_string)
  doc_or_string = Nokogiri.parse(doc_or_string) if doc_or_string.is_a?(String)
  EquivalentXml.equivalent?(self.xml, doc_or_string, element_order: true, normalize_whitespace: true)
end

#footer?(title) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/karasuba/note.rb', line 23

def footer?(title)
  !!self.xml.xpath("//*[attribute::title=\"#{title}\"]").last
end