Class: HorizonClient::Collection
- Inherits:
-
Object
- Object
- HorizonClient::Collection
- Includes:
- Enumerable
- Defined in:
- lib/horizon_client/collection.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #build ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(node) ⇒ Collection
constructor
A new instance of Collection.
- #rows ⇒ Object
Constructor Details
#initialize(node) ⇒ Collection
Returns a new instance of Collection.
7 8 9 10 11 12 |
# File 'lib/horizon_client/collection.rb', line 7 def initialize(node) @node = node @rows = @node.locate(row_element_name).map do |row| Entity.new(row) end end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
5 6 7 |
# File 'lib/horizon_client/collection.rb', line 5 def node @node end |
Instance Method Details
#build ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/horizon_client/collection.rb', line 14 def build row = Ox::Element.new(row_element_name) node << row entity = Entity.new(row) @rows.push(entity) entity end |
#each(&block) ⇒ Object
26 27 28 |
# File 'lib/horizon_client/collection.rb', line 26 def each(&block) @rows.each(&block) end |
#rows ⇒ Object
22 23 24 |
# File 'lib/horizon_client/collection.rb', line 22 def rows @rows end |