Class: Hive::Controller
- Inherits:
-
Object
- Object
- Hive::Controller
- Defined in:
- lib/hive/controller.rb,
lib/hive/controller/shell.rb
Overview
Generic hive controller class
Direct Known Subclasses
Defined Under Namespace
Classes: DeviceDetectionFailed, NoPortsAvailable, Shell
Instance Attribute Summary collapse
-
#port_range_size ⇒ Object
readonly
Returns the value of attribute port_range_size.
Instance Method Summary collapse
- #create_device(extra_options = {}) ⇒ Object
- #detect ⇒ Object
-
#initialize(config = {}) ⇒ Controller
constructor
A new instance of Controller.
Constructor Details
#initialize(config = {}) ⇒ Controller
Returns a new instance of Controller.
14 15 16 17 18 19 20 |
# File 'lib/hive/controller.rb', line 14 def initialize(config = {}) @config = config @device_class = self.class.to_s.sub('Controller', 'Device') require @device_class.downcase.gsub(/::/, '/') Hive.logger.info("Controller '#{self.class}' created") @port_range_size = (@config.has_key?('port_range_size') ? @config['port_range_size'] : 0) end |
Instance Attribute Details
#port_range_size ⇒ Object (readonly)
Returns the value of attribute port_range_size.
6 7 8 |
# File 'lib/hive/controller.rb', line 6 def port_range_size @port_range_size end |
Instance Method Details
#create_device(extra_options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/hive/controller.rb', line 22 def create_device( = {}) object = Object @device_class.split('::').each { |sub| object = object.const_get(sub) } object.new(@config.merge()) end |
#detect ⇒ Object
28 29 30 |
# File 'lib/hive/controller.rb', line 28 def detect raise NotImplementedError, "'detect' method not defined for '#{self.class}'" end |