Class: Circuits::Terminal::Input

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

Overview

Reads from a single output, only assigned to one component

Instance Attribute Summary collapse

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



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

def initialize(opts = {})
  @output = opts[:output] || Circuits::Terminal::Output.new
end

Instance Attribute Details

#outputObject

The output the input reads from



15
16
17
# File 'lib/circuits/terminal/input.rb', line 15

def output
  @output
end

Instance Method Details

#getBoolean

Forward get to the output

Returns:

  • (Boolean)

    The state of the output



19
20
21
# File 'lib/circuits/terminal/input.rb', line 19

def get
  @output.get
end

#set(s) ⇒ Object

Create a new output to use

Parameters:

  • s (Boolean)

    The state of the output to create



25
26
27
# File 'lib/circuits/terminal/input.rb', line 25

def set(s)
  @output = Circuits::Terminal::Output.new(state: s)
end