Class: Dozuki::NodeCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/dozuki/node_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection) ⇒ NodeCollection

Returns a new instance of NodeCollection.



5
6
7
# File 'lib/dozuki/node_collection.rb', line 5

def initialize(collection)
  self.collection = collection
end

Instance Attribute Details

#collectionObject

Returns the value of attribute collection.



3
4
5
# File 'lib/dozuki/node_collection.rb', line 3

def collection
  @collection
end

Instance Method Details

#as_boolean(&blk) ⇒ Object



29
30
31
# File 'lib/dozuki/node_collection.rb', line 29

def as_boolean(&blk)
  each_as(Parsers::Boolean, &blk)
end

#as_date(&blk) ⇒ Object



25
26
27
# File 'lib/dozuki/node_collection.rb', line 25

def as_date(&blk)
  each_as(Parsers::Date, &blk)
end

#as_float(&blk) ⇒ Object



21
22
23
# File 'lib/dozuki/node_collection.rb', line 21

def as_float(&blk)
  each_as(Parsers::Float, &blk)
end

#as_int(&blk) ⇒ Object



17
18
19
# File 'lib/dozuki/node_collection.rb', line 17

def as_int(&blk)
  each_as(Parsers::Integer, &blk)
end

#as_node(&blk) ⇒ Object



9
10
11
# File 'lib/dozuki/node_collection.rb', line 9

def as_node(&blk)
  collection.each{|item| blk.call(Node.new(item))}
end

#as_string(&blk) ⇒ Object



13
14
15
# File 'lib/dozuki/node_collection.rb', line 13

def as_string(&blk)
  each_as(Parsers::String, &blk)
end