Class: Subduino::Parse::Digital

Inherits:
Object
  • Object
show all
Defined in:
lib/subduino/parse.rb

Direct Known Subclasses

Analogic, Bool, Presence

Instance Method Summary collapse

Constructor Details

#initialize(v, n = nil, id = nil) ⇒ Digital

Returns a new instance of Digital.



10
11
12
13
14
# File 'lib/subduino/parse.rb', line 10

def initialize(v,n=nil,id=nil)
  @v = v.to_i
  @id = id
  @name = n
end

Instance Method Details

#digital?Boolean

Returns:

  • (Boolean)


15
# File 'lib/subduino/parse.rb', line 15

def digital?; true;   end

#graph(period) ⇒ Object



27
28
29
# File 'lib/subduino/parse.rb', line 27

def graph(period)
  Store.redis
end

#nameObject



17
# File 'lib/subduino/parse.rb', line 17

def name; @name; end

#rawObject



21
# File 'lib/subduino/parse.rb', line 21

def raw; @v; end

#sparkline(range = [-50, -1]) ⇒ Object



23
24
25
# File 'lib/subduino/parse.rb', line 23

def sparkline(range = [-50, -1])
  Store.redis.lrange "#{@id}_log", *range
end

#to_sObject



16
# File 'lib/subduino/parse.rb', line 16

def to_s; @v.to_s; end

#typeObject



18
19
20
# File 'lib/subduino/parse.rb', line 18

def type
  self.class.to_s.split("::")[-1].downcase # ugly
end