Class: Circuits::Terminal::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/circuits/terminal/input.rb

Overview

Reads from a single output

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Input

Creates the input

Parameters:

  • opts (Hash) (defaults to: {})

    Options to create the Input with

Options Hash (opts):

  • :output (Component::Output)

    The output to read from



11
12
13
# File 'lib/circuits/terminal/input.rb', line 11

def initialize(opts = {})
  @terminal = opts[:terminal] || Output.new(state: opts[:state])
end

Instance Method Details

#getBoolean

Forward get to the output

Returns:

  • (Boolean)

    The state of the output



17
18
19
# File 'lib/circuits/terminal/input.rb', line 17

def get
  @terminal.get
end

#set(output) ⇒ Object

Output to use or state to make a dummy output with

Parameters:

  • output (Output, Boolean)

    The output to read from, or state



23
24
25
26
27
28
29
# File 'lib/circuits/terminal/input.rb', line 23

def set(output)
  if [Input, Output].include? output.class
    @terminal = output
  else
    @terminal = Output.new(state: output)
  end
end