Class: I2C::AlphaDisplayApp

Inherits:
Object
  • Object
show all
Defined in:
lib/i2c/alpha_display_app.rb

Instance Method Summary collapse

Instance Method Details

#mainObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/i2c/alpha_display_app.rb', line 6

def main
    @display = AlphaDisplay.new(0x70)

    STDIN.each_line do |line|
        begin
            a = parse_line(line)
            @display.set a
        rescue => e
            puts e.to_s
        end
    end
    
end

#parse_line(s) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/i2c/alpha_display_app.rb', line 20

def parse_line(s)
    s.strip!

    if s.to_i.to_s == s
        return s.to_i
    end

    begin
        return Float(s)
    rescue
        return s
    end
end