Class: Cuenote::Api::Node

Inherits:
Base
  • Object
show all
Defined in:
lib/cuenote/api/node.rb

Direct Known Subclasses

AddressBook, Result

Instance Method Summary collapse

Methods inherited from Base

connection, #connection, run, #run

Constructor Details

#initialize(doc = nil) ⇒ Node

Returns a new instance of Node.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/cuenote/api/node.rb', line 7

def initialize(doc=nil)
  @doc =
    case doc
    when REXML::Element
      doc
    when String
      REXML::Document.new(doc)
    else
      REXML::Document.new('<a/>')
    end
end

Instance Method Details

#attributesObject



19
20
21
22
23
24
# File 'lib/cuenote/api/node.rb', line 19

def attributes
  @attributes ||= @doc.attributes.inject({}) do
    |hash, attr| hash[attr[0].to_sym] = attr[1]
    hash
  end
end

#elementsObject



26
27
28
# File 'lib/cuenote/api/node.rb', line 26

def elements
  @doc.elements
end