Class: Avm::Data::Package

Inherits:
Object show all
Defined in:
lib/avm/data/package.rb,
lib/avm/data/package/dump.rb,
lib/avm/data/package/load.rb

Direct Known Subclasses

Instance::Package

Defined Under Namespace

Classes: Dump, Load

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options)
  @units = {}
  options = options.to_options_consumer
  units = options.consume(:units)
  options.validate
  units.if_present do |v|
    v.each { |identifier, unit| add_unit(identifier, unit) }
  end
end

Instance Attribute Details

#unitsObject (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, options = {})
  ::Avm::Data::Package::Dump.new(self, data_path, options)
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