Class: Fir::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/fir/key.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Key

Returns a new instance of Key.



8
9
10
# File 'lib/fir/key.rb', line 8

def initialize(input)
  @input = input
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



6
7
8
# File 'lib/fir/key.rb', line 6

def input
  @input
end

Instance Method Details

#getObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fir/key.rb', line 12

def get
  input.raw do |raw_input|
    key = raw_input.sysread(1).chr
    if key == "\e"
      skt = Thread.new { 2.times { key += raw_input.sysread(1).chr } }
      skt.join(0.0001)
      skt.kill
    end
    key
  end
end