Class: Plumbus::LoaderDSL
- Inherits:
-
Object
- Object
- Plumbus::LoaderDSL
- Defined in:
- lib/plumbus/loader.rb
Instance Attribute Summary collapse
-
#ports ⇒ Object
readonly
Returns the value of attribute ports.
Instance Method Summary collapse
-
#initialize(src_path) ⇒ LoaderDSL
constructor
A new instance of LoaderDSL.
- #port(direction, driver, &config_block) ⇒ Object
Constructor Details
#initialize(src_path) ⇒ LoaderDSL
Returns a new instance of LoaderDSL.
31 32 33 34 35 36 |
# File 'lib/plumbus/loader.rb', line 31 def initialize src_path @ports = [] contents = File.read(src_path) instance_eval contents, src_path end |
Instance Attribute Details
#ports ⇒ Object (readonly)
Returns the value of attribute ports.
29 30 31 |
# File 'lib/plumbus/loader.rb', line 29 def ports @ports end |
Instance Method Details
#port(direction, driver, &config_block) ⇒ Object
38 39 40 41 42 |
# File 'lib/plumbus/loader.rb', line 38 def port direction, driver, &config_block raise ArgumentError, "The given direction #{direction.inspect} was not a valid direction. Valid directions include #{Port::SUPPORTED_DIRECTIONS.inspect}" unless Port::SUPPORTED_DIRECTIONS.include? direction raise ArgumentError, "No config block was given for the port #{direction.inspect}, #{driver.inspect}" unless config_block @ports << {:direction => direction, :driver => driver, :config_block => config_block} end |