Class: Comet::DSL::Firmware
- Inherits:
-
Object
- Object
- Comet::DSL::Firmware
- Includes:
- Helpers
- Defined in:
- lib/comet/dsl/firmware.rb
Instance Attribute Summary collapse
-
#imports ⇒ Object
Returns the value of attribute imports.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #hardware_for(device) ⇒ Object
-
#initialize(name, imports:, &block) ⇒ Firmware
constructor
A new instance of Firmware.
- #target(device, &block) ⇒ Object
- #target_for(device) ⇒ Object
- #targets ⇒ Object
- #to_s ⇒ Object
- #validate! ⇒ Object
Methods included from Helpers
Constructor Details
#initialize(name, imports:, &block) ⇒ Firmware
Returns a new instance of Firmware.
12 13 14 15 16 17 18 |
# File 'lib/comet/dsl/firmware.rb', line 12 def initialize(name, imports:, &block) @name = name @imports = imports @targets = {} instance_exec(&block) if block_given? end |
Instance Attribute Details
#imports ⇒ Object
Returns the value of attribute imports.
25 26 27 |
# File 'lib/comet/dsl/firmware.rb', line 25 def imports @imports end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/comet/dsl/firmware.rb', line 24 def name @name end |
Instance Method Details
#hardware_for(device) ⇒ Object
35 36 37 38 39 |
# File 'lib/comet/dsl/firmware.rb', line 35 def hardware_for(device) @imports.flat_map do |imported| imported.hardware_for device end.uniq end |
#target(device, &block) ⇒ Object
7 8 9 10 |
# File 'lib/comet/dsl/firmware.rb', line 7 def target(device, &block) raise "target #{device} redefined" if @targets.key? device @targets[device] = Target.new(device, &block) end |
#target_for(device) ⇒ Object
31 32 33 |
# File 'lib/comet/dsl/firmware.rb', line 31 def target_for(device) @targets[device] end |
#targets ⇒ Object
27 28 29 |
# File 'lib/comet/dsl/firmware.rb', line 27 def targets @targets.keys end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/comet/dsl/firmware.rb', line 20 def to_s "firmware #{@name}" end |
#validate! ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/comet/dsl/firmware.rb', line 41 def validate! raise "firmware `#{@name}' has no targets" if @targets.empty? @targets.values.each(&:validate!) imports.each(&:validate!) targets.each do |device| validate_for! device, hardware_for(device) end end |