Class: HorizonClient::Entity
- Inherits:
-
Object
- Object
- HorizonClient::Entity
- Defined in:
- lib/horizon_client/entity.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
- #get_collection(name) ⇒ Object
-
#initialize(node) ⇒ Entity
constructor
A new instance of Entity.
Constructor Details
#initialize(node) ⇒ Entity
Returns a new instance of Entity.
5 6 7 |
# File 'lib/horizon_client/entity.rb', line 5 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
3 4 5 |
# File 'lib/horizon_client/entity.rb', line 3 def node @node end |
Instance Method Details
#[](name) ⇒ Object
9 10 11 12 |
# File 'lib/horizon_client/entity.rb', line 9 def [](name) attr_node = node.locate(name).first get_value attr_node end |
#[]=(name, value) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/horizon_client/entity.rb', line 14 def []=(name, value) elem = find_or_build_attribute(name.split('/'), node) # needed in case element is in '</elem>' form check = elem.text elem.replace_text(value) end |
#get_collection(name) ⇒ Object
23 24 25 26 |
# File 'lib/horizon_client/entity.rb', line 23 def get_collection(name) collection_node = find_or_build_attribute(name.split('/'), node) Collection.new(collection_node) end |