Class: Rockbox::Api::Sound

Inherits:
Object
  • Object
show all
Defined in:
lib/rockbox/api/sound.rb

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Sound

Returns a new instance of Sound.



8
9
10
# File 'lib/rockbox/api/sound.rb', line 8

def initialize(http)
  @http = http
end

Instance Method Details

#adjust(steps) ⇒ Integer

Adjust volume by N steps (positive = louder, negative = quieter).

Returns:

  • (Integer)

    resulting volume



20
21
22
23
24
25
# File 'lib/rockbox/api/sound.rb', line 20

def adjust(steps)
  @http.execute(
    "mutation AdjustVolume($steps: Int!) { adjustVolume(steps: $steps) }",
    { steps: steps }
  )[:adjust_volume]
end

#downObject



28
# File 'lib/rockbox/api/sound.rb', line 28

def down; adjust(-1); end

#upObject



27
# File 'lib/rockbox/api/sound.rb', line 27

def up;   adjust(1);  end

#volumeRockbox::VolumeInfo

Returns:



13
14
15
16
# File 'lib/rockbox/api/sound.rb', line 13

def volume
  data = @http.execute("query Volume { volume { volume min max } }")
  VolumeInfo.from_hash(data[:volume])
end