class Battman::Battery

Constants

CONVERSIONS

Public Class Methods

new(battery_index = 0, **opts) click to toggle source
# File lib/battman/battery.rb, line 24
def initialize(battery_index = 0, **opts)
  if self.class == Battery
    raise AbstractError.new('cannot instantiate Battery')
  end

  @index = battery_index
end

Public Instance Methods

full_energy() click to toggle source
# File lib/battman/battery.rb, line 88
def full_energy
  raise NotImplementedError.new
end
full_energy_in(unit) click to toggle source
# File lib/battman/battery.rb, line 92
def full_energy_in(unit)
  unless unit.in?(CONVERSIONS[:energy].keys)
    raise UnsupportedUnitError.new(unit)
  end

  CONVERSIONS[:energy][unit].call(full_energy)
end
power() click to toggle source
# File lib/battman/battery.rb, line 40
def power
  raise NotImplementedError.new
end
power_in(unit) click to toggle source
# File lib/battman/battery.rb, line 44
def power_in(unit)
  unless unit.in?(CONVERSIONS[:power].keys)
    raise UnsupportedUnitError.new(unit)
  end

  CONVERSIONS[:power][unit].call(power)
end
remaining_charging_time() click to toggle source
# File lib/battman/battery.rb, line 64
def remaining_charging_time
  raise NotImplementedError.new
end
remaining_charging_time_in(unit) click to toggle source
# File lib/battman/battery.rb, line 68
def remaining_charging_time_in(unit)
  unless unit.in?(CONVERSIONS[:time].keys)
    raise UnsupportedUnitError.new(unit)
  end

  CONVERSIONS[:time][unit].call(remaining_charging_time)
end
remaining_energy() click to toggle source
# File lib/battman/battery.rb, line 76
def remaining_energy
  raise NotImplementedError.new
end
remaining_energy_in(unit) click to toggle source
# File lib/battman/battery.rb, line 80
def remaining_energy_in(unit)
  unless unit.in?(CONVERSIONS[:energy].keys)
    raise UnsupportedUnitError.new(unit)
  end

  CONVERSIONS[:energy][unit].call(remaining_energy)
end
remaining_percent() click to toggle source
# File lib/battman/battery.rb, line 36
def remaining_percent
  raise NotImplementedError.new
end
remaining_running_time() click to toggle source
# File lib/battman/battery.rb, line 52
def remaining_running_time
  raise NotImplementedError.new
end
remaining_running_time_in(unit) click to toggle source
# File lib/battman/battery.rb, line 56
def remaining_running_time_in(unit)
  unless unit.in?(CONVERSIONS[:time].keys)
    raise UnsupportedUnitError.new(unit)
  end

  CONVERSIONS[:time][unit].call(remaining_running_time)
end
state() click to toggle source
# File lib/battman/battery.rb, line 32
def state
  raise NotImplementedError.new
end