Class: ConfigLogic::Multiplexer
- Inherits:
-
LogicElement
- Object
- LogicElement
- ConfigLogic::Multiplexer
- Defined in:
- lib/config_logic/multiplexer.rb
Constant Summary
Constants inherited from LogicElement
LogicElement::MIN_INPUTS, LogicElement::NAME, LogicElement::STATIC
Constants included from Logger::Colors
Logger::Colors::BLUE, Logger::Colors::GREEN, Logger::Colors::RED, Logger::Colors::RESET, Logger::Colors::YELLOW
Instance Attribute Summary collapse
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
Attributes inherited from LogicElement
Instance Method Summary collapse
-
#initialize(params) ⇒ Multiplexer
constructor
A new instance of Multiplexer.
- #output ⇒ Object
Methods inherited from LogicElement
available_elements, inherited, #input_names, name_to_type, #set_input, #static?
Methods included from Logger
Constructor Details
#initialize(params) ⇒ Multiplexer
Returns a new instance of Multiplexer.
5 6 7 8 9 10 |
# File 'lib/config_logic/multiplexer.rb', line 5 def initialize(params) super @multiplexer = params[:inputs] @inputs = HashWithIndifferentAccess.new(@multiplexer.values.to_hash) @selector = params[:selector] end |
Instance Attribute Details
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
3 4 5 |
# File 'lib/config_logic/multiplexer.rb', line 3 def selector @selector end |
Instance Method Details
#output ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/config_logic/multiplexer.rb', line 12 def output return unless inputs_valid? case @selector when Proc @inputs[@multiplexer[@selector.call]] else @inputs[@multiplexer[@selector]] end end |