Class: Ygg::DataBundle
- Inherits:
-
Object
- Object
- Ygg::DataBundle
- Defined in:
- lib/ygg/databundle.rb
Instance Method Summary collapse
- #<<(*args) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#first ⇒ Object
Delegate to array.
- #include?(*args) ⇒ Boolean
-
#initialize(source_array = nil) ⇒ DataBundle
constructor
A new instance of DataBundle.
- #last ⇒ Object
- #length ⇒ Object
- #of_type(type) ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(source_array = nil) ⇒ DataBundle
Returns a new instance of DataBundle.
3 4 5 |
# File 'lib/ygg/databundle.rb', line 3 def initialize(source_array = nil) @data = source_array || [] end |
Instance Method Details
#<<(*args) ⇒ Object
18 |
# File 'lib/ygg/databundle.rb', line 18 def <<(*args); @data.<<(*args); end |
#each(&block) ⇒ Object
21 |
# File 'lib/ygg/databundle.rb', line 21 def each(&block); @data.each { |e| block.call(e) }; end |
#empty? ⇒ Boolean
17 |
# File 'lib/ygg/databundle.rb', line 17 def empty?; @data.empty?; end |
#first ⇒ Object
Delegate to array
16 |
# File 'lib/ygg/databundle.rb', line 16 def first; @data.first; end |
#include?(*args) ⇒ Boolean
20 |
# File 'lib/ygg/databundle.rb', line 20 def include?(*args); @data.include?(*args); end |
#last ⇒ Object
23 |
# File 'lib/ygg/databundle.rb', line 23 def last; @data.last; end |
#length ⇒ Object
22 |
# File 'lib/ygg/databundle.rb', line 22 def length; @data.length; end |
#of_type(type) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/ygg/databundle.rb', line 7 def of_type(type) @result = DataBundle.new @data.each do |resource| @result << resource if resource.instance_of? type end return @result.empty? ? nil : @result end |
#to_yaml ⇒ Object
19 |
# File 'lib/ygg/databundle.rb', line 19 def to_yaml; @data.to_yaml; end |