Class: ASIN::SimpleNode

Inherits:
Object
  • Object
show all
Defined in:
lib/asin/simple_node.rb

Overview

SimpleNode

The SimpleNode class is a wrapper for the Amazon XML-REST-Response.

A Hashie::Mash is used for the internal data representation and can be accessed over the raw attribute.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ SimpleNode

Returns a new instance of SimpleNode.



15
16
17
# File 'lib/asin/simple_node.rb', line 15

def initialize(hash)
  @raw = Hashie::Mash.new(hash)
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



13
14
15
# File 'lib/asin/simple_node.rb', line 13

def raw
  @raw
end

Instance Method Details

#ancestorsObject



32
33
34
35
# File 'lib/asin/simple_node.rb', line 32

def ancestors
  return [] unless @raw.Ancestors
  @raw.Ancestors.BrowseNode.is_a?(Array) ? @raw.Ancestors.BrowseNode : [@raw.Ancestors.BrowseNode]
end

#childrenObject



27
28
29
30
# File 'lib/asin/simple_node.rb', line 27

def children
  return [] unless @raw.Children
  @raw.Children.BrowseNode.is_a?(Array) ? @raw.Children.BrowseNode : [@raw.Children.BrowseNode]
end

#nameObject



19
20
21
# File 'lib/asin/simple_node.rb', line 19

def name
  @raw.Name
end

#node_idObject



23
24
25
# File 'lib/asin/simple_node.rb', line 23

def node_id
  @raw.BrowseNodeId
end

#top_item_setObject



37
38
39
40
# File 'lib/asin/simple_node.rb', line 37

def top_item_set
  return [] unless @raw.TopItemSet
  @raw.TopItemSet.TopItem.is_a?(Array) ? @raw.TopItemSet.TopItem : [@raw.TopItemSet.TopItem]
end