class Roowifi::Status

Constants

MAPPING

Attributes

values[R]

Public Class Methods

new(values) click to toggle source
# File lib/roowifi/status.rb, line 25
def initialize(values)
  @values = values
end

Public Instance Methods

battery_level() click to toggle source
# File lib/roowifi/status.rb, line 37
def battery_level
  ((100 / capacity.to_f) * charge.to_f).to_i
end
charging?() click to toggle source
# File lib/roowifi/status.rb, line 33
def charging?
  charging_state == 2
end
method_missing(method, *args) click to toggle source
Calls superclass method
# File lib/roowifi/status.rb, line 41
def method_missing(method, *args)
  super(method, *args) unless MAPPING.key?(method)
  value(MAPPING[method])&.to_i
end
wall?() click to toggle source
# File lib/roowifi/status.rb, line 29
def wall?
  wall != 0
end

Private Instance Methods

value(id) click to toggle source
# File lib/roowifi/status.rb, line 50
def value(id)
  values.dig('response', "r#{id}", 'value')
end