Class: Raudi::AVR::Controller

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
StateList
Defined in:
lib/raudi/avr/controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_name, &block) ⇒ Controller

Returns a new instance of Controller.



18
19
20
21
22
23
24
25
# File 'lib/raudi/avr/controller.rb', line 18

def initialize(model_name, &block)
  self.model_name = model_name
  load_ports
  load_timers
  self.headers = ['avr/io']
  Proxy::Controller.new(self, &block) if block_given?
  Raudi.controller = self
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (private)



61
62
63
64
65
66
67
# File 'lib/raudi/avr/controller.rb', line 61

def method_missing(method_name, *args, &block)
  if value = config[method_name.to_s]
    value
  else
    super
  end
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



14
15
16
# File 'lib/raudi/avr/controller.rb', line 14

def headers
  @headers
end

#interruptObject

Returns the value of attribute interrupt.



14
15
16
# File 'lib/raudi/avr/controller.rb', line 14

def interrupt
  @interrupt
end

#model_nameObject

Returns the value of attribute model_name.



14
15
16
# File 'lib/raudi/avr/controller.rb', line 14

def model_name
  @model_name
end

#ports(port_name = nil) ⇒ Object

Returns the value of attribute ports.



14
15
16
# File 'lib/raudi/avr/controller.rb', line 14

def ports
  @ports
end

#timersObject

Returns the value of attribute timers.



14
15
16
# File 'lib/raudi/avr/controller.rb', line 14

def timers
  @timers
end

Instance Method Details

#pinsObject



35
36
37
# File 'lib/raudi/avr/controller.rb', line 35

def pins
  ports.map(&:pins).flatten
end

#sourceObject



39
40
41
# File 'lib/raudi/avr/controller.rb', line 39

def source
  @source ||= Source::Controller.new(self)
end