Class: Avm::Data::Package
- Defined in:
- lib/avm/data/package.rb,
lib/avm/data/package/dump.rb,
lib/avm/data/package/load.rb
Direct Known Subclasses
Defined Under Namespace
Instance Attribute Summary collapse
-
#units ⇒ Object
readonly
Returns the value of attribute units.
Instance Method Summary collapse
- #add_unit(identifier, unit) ⇒ Object
- #dump(data_path, options = {}) ⇒ Object
- #dump_units_to_directory(directory) ⇒ Object
-
#initialize(options) ⇒ Package
constructor
A new instance of Package.
- #load(data_path) ⇒ Object
- #load_units_from_directory(directory) ⇒ Object
Constructor Details
#initialize(options) ⇒ Package
Returns a new instance of Package.
11 12 13 14 15 16 17 18 19 |
# File 'lib/avm/data/package.rb', line 11 def initialize() @units = {} = . units = .consume(:units) .validate units.if_present do |v| v.each { |identifier, unit| add_unit(identifier, unit) } end end |
Instance Attribute Details
#units ⇒ Object (readonly)
Returns the value of attribute units.
9 10 11 |
# File 'lib/avm/data/package.rb', line 9 def units @units end |
Instance Method Details
#add_unit(identifier, unit) ⇒ Object
21 22 23 |
# File 'lib/avm/data/package.rb', line 21 def add_unit(identifier, unit) @units[identifier.to_sym] = unit end |
#dump(data_path, options = {}) ⇒ Object
25 26 27 |
# File 'lib/avm/data/package.rb', line 25 def dump(data_path, = {}) ::Avm::Data::Package::Dump.new(self, data_path, ) end |
#dump_units_to_directory(directory) ⇒ Object
33 34 35 |
# File 'lib/avm/data/package.rb', line 33 def dump_units_to_directory(directory) @units.each { |identifier, unit| unit.dump_to_directory(directory, identifier) } end |
#load(data_path) ⇒ Object
29 30 31 |
# File 'lib/avm/data/package.rb', line 29 def load(data_path) ::Avm::Data::Package::Load.new(self, data_path) end |
#load_units_from_directory(directory) ⇒ Object
37 38 39 |
# File 'lib/avm/data/package.rb', line 37 def load_units_from_directory(directory) @units.each { |identifier, unit| unit.load_from_directory(directory, identifier) } end |