Class: Comet::DSL::Hardware
- Inherits:
-
Object
- Object
- Comet::DSL::Hardware
- Includes:
- Helpers
- Defined in:
- lib/comet/dsl/hardware.rb
Instance Attribute Summary collapse
-
#linker_ ⇒ Object
readonly
Returns the value of attribute linker_.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
- #hardware_for(device) ⇒ Object
- #import(name, path: nil) ⇒ Object
-
#initialize(name, targets:, &block) ⇒ Hardware
constructor
A new instance of Hardware.
- #libraries ⇒ Object
- #linker(*args, **kwargs, &block) ⇒ Object
- #linker? ⇒ Boolean
- #source(language:, **kwargs, &block) ⇒ Object
- #to_s ⇒ Object
- #validate! ⇒ Object
Methods included from Helpers
Constructor Details
#initialize(name, targets:, &block) ⇒ Hardware
Returns a new instance of Hardware.
20 21 22 23 24 25 26 27 28 |
# File 'lib/comet/dsl/hardware.rb', line 20 def initialize(name, targets:, &block) @name = name @targets = targets @sources = [] @linker_ = nil @libraries = Set[] instance_exec(&block) if block_given? end |
Instance Attribute Details
#linker_ ⇒ Object (readonly)
Returns the value of attribute linker_.
36 37 38 |
# File 'lib/comet/dsl/hardware.rb', line 36 def linker_ @linker_ end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
35 36 37 |
# File 'lib/comet/dsl/hardware.rb', line 35 def sources @sources end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
34 35 36 |
# File 'lib/comet/dsl/hardware.rb', line 34 def targets @targets end |
Instance Method Details
#hardware_for(device) ⇒ Object
42 43 44 |
# File 'lib/comet/dsl/hardware.rb', line 42 def hardware_for(device) device == targets ? self : [] end |
#import(name, path: nil) ⇒ Object
16 17 18 |
# File 'lib/comet/dsl/hardware.rb', line 16 def import(name, path: nil) @libraries.add Library.new(name, path: path) end |
#libraries ⇒ Object
38 39 40 |
# File 'lib/comet/dsl/hardware.rb', line 38 def libraries @libraries.to_a end |
#linker(*args, **kwargs, &block) ⇒ Object
11 12 13 14 |
# File 'lib/comet/dsl/hardware.rb', line 11 def linker(*args, **kwargs, &block) raise 'linker section redefined' unless @linker_.nil? @linker_ = Linker.new(*args, **kwargs, &block) end |
#linker? ⇒ Boolean
46 47 48 |
# File 'lib/comet/dsl/hardware.rb', line 46 def linker? !@linker_.nil? end |
#source(language:, **kwargs, &block) ⇒ Object
7 8 9 |
# File 'lib/comet/dsl/hardware.rb', line 7 def source(language:, **kwargs, &block) @sources.push Source.create(language: language, **kwargs, &block) end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/comet/dsl/hardware.rb', line 30 def to_s "hardware #{@name} for #{@targets}" end |
#validate! ⇒ Object
50 51 52 53 |
# File 'lib/comet/dsl/hardware.rb', line 50 def validate! sources.each(&:validate!) @linker.validate! unless @linker.nil? end |