Class: Plumbus::LoaderDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/plumbus/loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#portsObject (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

Raises:

  • (ArgumentError)


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