Class: Yamo::Collection
- Extended by:
- Enumerable
- Defined in:
- lib/yamo/collection.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Object
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, data) ⇒ Collection
constructor
A new instance of Collection.
-
#to_s ⇒ Object
Include name in
to_s
.
Methods inherited from Object
create_accessors, load_and_validate_file, load_and_validate_source, schema, validate_data, validator
Constructor Details
#initialize(name, data) ⇒ Collection
Returns a new instance of Collection.
13 14 15 16 |
# File 'lib/yamo/collection.rb', line 13 def initialize(name, data) @name = name @data = data end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/yamo/collection.rb', line 11 def name @name end |
Class Method Details
.each ⇒ Object
30 31 32 33 34 35 |
# File 'lib/yamo/collection.rb', line 30 def self.each Dir.foreach(@objectdir) do |o| next if o.match(/^\./) yield get(o) end end |
.get(name) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/yamo/collection.rb', line 22 def self.get(name) begin self.new(name, load_and_validate_file("#{@objectdir}/#{name}")) rescue Errno::ENOENT nil end end |
.objectdir(objectdir) ⇒ Object
18 19 20 |
# File 'lib/yamo/collection.rb', line 18 def self.objectdir(objectdir) @objectdir = objectdir end |
Instance Method Details
#to_s ⇒ Object
Include name in to_s
38 39 40 |
# File 'lib/yamo/collection.rb', line 38 def to_s return '#<' + self.class.to_s + ":" + self.name + '>' end |