Class: Dommy::BatteryManager

Inherits:
Object
  • Object
show all
Includes:
EventTarget
Defined in:
lib/dommy/navigator.rb

Overview

‘navigator.getBattery()` returns one of these. Fixed snapshot —tests that need different values can stub.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EventTarget

#__deliver_event__, #add_event_listener, #dispatch_event, #invoke_listener, #remove_event_listener

Constructor Details

#initialize(charging: true, level: 1.0, charging_time: 0, discharging_time: Float::INFINITY) ⇒ BatteryManager

Returns a new instance of BatteryManager.



501
502
503
504
505
506
# File 'lib/dommy/navigator.rb', line 501

def initialize(charging: true, level: 1.0, charging_time: 0, discharging_time: Float::INFINITY)
  @charging = charging
  @level = level
  @charging_time = charging_time
  @discharging_time = discharging_time
end

Instance Attribute Details

#chargingObject (readonly)

Returns the value of attribute charging.



499
500
501
# File 'lib/dommy/navigator.rb', line 499

def charging
  @charging
end

#charging_timeObject (readonly)

Returns the value of attribute charging_time.



499
500
501
# File 'lib/dommy/navigator.rb', line 499

def charging_time
  @charging_time
end

#discharging_timeObject (readonly)

Returns the value of attribute discharging_time.



499
500
501
# File 'lib/dommy/navigator.rb', line 499

def discharging_time
  @discharging_time
end

#levelObject (readonly)

Returns the value of attribute level.



499
500
501
# File 'lib/dommy/navigator.rb', line 499

def level
  @level
end

Instance Method Details

#__event_parent__Object



521
522
523
# File 'lib/dommy/navigator.rb', line 521

def __event_parent__
  nil
end

#__js_get__(key) ⇒ Object



508
509
510
511
512
513
514
515
516
517
518
519
# File 'lib/dommy/navigator.rb', line 508

def __js_get__(key)
  case key
  when "charging"
    @charging
  when "chargingTime"
    @charging_time
  when "dischargingTime"
    @discharging_time
  when "level"
    @level
  end
end