Class: OEHClient::Data::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/oehclient/data/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Node

Returns a new instance of Node.

[View source]

6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/oehclient/data/node.rb', line 6

def initialize(data)

	# Raise an exception if the data passed is not already a hash

	# based on the type of object that is passed, create the proper attribute accessor
	#  to allow easy access to data.  For example, a simple value in the structure called
	#  firstName will be represented in the object as my_structure.first_name.  Simple
	#  object are represented as related node classes.  For example a Preference node with
	#  an attribute of nonSmokingRoom will be represented as my_structure.preference.non_smoking_room
	data.each do | key, value |
		(value.kind_of?(Array) ? add_collection(key, value) : add_attribute(key, value))
	end

end

Instance Attribute Details

#nodesObject

Returns the value of attribute nodes.


4
5
6
# File 'lib/oehclient/data/node.rb', line 4

def nodes
  @nodes
end

Instance Method Details

#attribute_namesObject

return the names of each of the attributes of the current nodes of the structure

[View source]

22
23
24
25
26
27
28
29
# File 'lib/oehclient/data/node.rb', line 22

def attribute_names()
	name_collection = Array.new
	instance_variable_names.each do | structure_attribute | 
		structure_attribute.slice!(0)
		name_collection << structure_attribute
	end
	name_collection
end