Class: Airstream::Io
- Inherits:
-
Object
- Object
- Airstream::Io
- Defined in:
- lib/airstream/io.rb
Constant Summary collapse
- KEY_QUIT =
'q'
- KEY_SKIP =
'>'
- KEY_PREV =
'<'
- KEY_FWD =
'.'
- KEY_BACK =
','
- KEY_PAUSE =
' '
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#quiet ⇒ Object
writeonly
Sets the attribute quiet.
-
#verbose ⇒ Object
writeonly
Sets the attribute verbose.
Class Method Summary collapse
Instance Method Summary collapse
- #back? ⇒ Boolean
- #catch_input ⇒ Object
- #error(msg) ⇒ Object
- #fwd? ⇒ Boolean
- #info(msg) ⇒ Object
- #pause? ⇒ Boolean
- #prev? ⇒ Boolean
- #print(msg) ⇒ Object
- #puts(msg) ⇒ Object
- #quit? ⇒ Boolean
- #skip? ⇒ Boolean
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
14 15 16 |
# File 'lib/airstream/io.rb', line 14 def key @key end |
#quiet=(value) ⇒ Object (writeonly)
Sets the attribute quiet
13 14 15 |
# File 'lib/airstream/io.rb', line 13 def quiet=(value) @quiet = value end |
#verbose=(value) ⇒ Object (writeonly)
Sets the attribute verbose
13 14 15 |
# File 'lib/airstream/io.rb', line 13 def verbose=(value) @verbose = value end |
Class Method Details
.hide_input ⇒ Object
32 33 34 |
# File 'lib/airstream/io.rb', line 32 def self.hide_input `stty raw -echo` end |
.show_input ⇒ Object
36 37 38 |
# File 'lib/airstream/io.rb', line 36 def self.show_input `stty -raw echo` end |
Instance Method Details
#catch_input ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/airstream/io.rb', line 40 def catch_input @key = nil if STDIN.ready? @key = STDIN.getc end rescue show_input end |
#error(msg) ⇒ Object
28 29 30 |
# File 'lib/airstream/io.rb', line 28 def error(msg) STDERR.puts msg end |
#info(msg) ⇒ Object
24 25 26 |
# File 'lib/airstream/io.rb', line 24 def info(msg) STDOUT.puts msg if @verbose end |
#print(msg) ⇒ Object
16 17 18 |
# File 'lib/airstream/io.rb', line 16 def print(msg) STDOUT.print msg unless @quiet end |
#puts(msg) ⇒ Object
20 21 22 |
# File 'lib/airstream/io.rb', line 20 def puts(msg) STDOUT.puts msg unless @quiet end |