Class: LD220
- Inherits:
-
Object
- Object
- LD220
- Defined in:
- lib/ld220.rb,
lib/ld220/version.rb,
lib/ld220/mode/utc.rb
Defined Under Namespace
Classes: Mode
Constant Summary collapse
- VERSION =
'0.0.1'
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
Instance Method Summary collapse
-
#initialize(device, mode, options = {}) ⇒ LD220
constructor
A new instance of LD220.
- #type(string, delay = 0.1) ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(device, mode, options = {}) ⇒ LD220
Returns a new instance of LD220.
7 8 9 10 11 12 |
# File 'lib/ld220.rb', line 7 def initialize(device, mode, = {}) extend mode [:speed] ||= 9600 @debug = [:debug] @display = Serial.new device, [:speed] end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
5 6 7 |
# File 'lib/ld220.rb', line 5 def debug @debug end |
Instance Method Details
#type(string, delay = 0.1) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/ld220.rb', line 14 def type(string, delay = 0.1) clear sleep delay string.split('').each do |char| write char sleep delay end end |
#write(data) ⇒ Object
23 24 25 26 27 |
# File 'lib/ld220.rb', line 23 def write(data) data = data.encode Encoding::US_ASCII puts "Sending: #{data.inspect}" if @debug @display.write data end |