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

#__internal_deliver_event__, #add_event_listener, capture_flag, #deliver_at, #dispatch_event, js_truthy?, #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.



511
512
513
514
515
516
# File 'lib/dommy/navigator.rb', line 511

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.



509
510
511
# File 'lib/dommy/navigator.rb', line 509

def charging
  @charging
end

#charging_timeObject (readonly)

Returns the value of attribute charging_time.



509
510
511
# File 'lib/dommy/navigator.rb', line 509

def charging_time
  @charging_time
end

#discharging_timeObject (readonly)

Returns the value of attribute discharging_time.



509
510
511
# File 'lib/dommy/navigator.rb', line 509

def discharging_time
  @discharging_time
end

#levelObject (readonly)

Returns the value of attribute level.



509
510
511
# File 'lib/dommy/navigator.rb', line 509

def level
  @level
end

Instance Method Details

#__internal_event_parent__Object



531
532
533
# File 'lib/dommy/navigator.rb', line 531

def __internal_event_parent__
  nil
end

#__js_get__(key) ⇒ Object



518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/dommy/navigator.rb', line 518

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