Class: RemoteDroid::Query
- Inherits:
-
Object
- Object
- RemoteDroid::Query
- Defined in:
- lib/remotedroid/query.rb
Instance Attribute Summary collapse
-
#locations ⇒ Object
Returns the value of attribute locations.
Class Method Summary collapse
Instance Method Summary collapse
- #airplane_mode_enabled? ⇒ Boolean
- #battery ⇒ Object
- #cell_id ⇒ Object (also: #cell_tower)
- #current_brightness ⇒ Object (also: #brightness)
-
#initialize(device, callback) ⇒ Query
constructor
A new instance of Query.
- #ip ⇒ Object
- #last_loc ⇒ Object
- #location ⇒ Object
- #power_connected? ⇒ Boolean
- #take_picture ⇒ Object
- #take_screenshot ⇒ Object
- #volume(context = nil) ⇒ Object (also: #vol)
Constructor Details
#initialize(device, callback) ⇒ Query
Returns a new instance of Query.
7 8 9 10 |
# File 'lib/remotedroid/query.rb', line 7 def initialize(device, callback) @device, @callback = device, callback @locations = [] end |
Instance Attribute Details
#locations ⇒ Object
Returns the value of attribute locations.
5 6 7 |
# File 'lib/remotedroid/query.rb', line 5 def locations @locations end |
Class Method Details
.alt ⇒ Object
38 |
# File 'lib/remotedroid/query.rb', line 38 def self.alt() q(:last_loc_alt) end |
.latlon ⇒ Object
39 |
# File 'lib/remotedroid/query.rb', line 39 def self.latlon() q(:last_latlong) end |
.link ⇒ Object
40 |
# File 'lib/remotedroid/query.rb', line 40 def self.link() q(:last_loc_link) end |
.time ⇒ Object
41 |
# File 'lib/remotedroid/query.rb', line 41 def self.time() q(:last_loc_age_timestamp) end |
Instance Method Details
#airplane_mode_enabled? ⇒ Boolean
12 13 14 |
# File 'lib/remotedroid/query.rb', line 12 def airplane_mode_enabled?() q(:airplane_mode_on).to_i > 0 end |
#battery ⇒ Object
16 17 18 |
# File 'lib/remotedroid/query.rb', line 16 def battery() q(:battery).to_i end |
#cell_id ⇒ Object Also known as: cell_tower
26 27 28 |
# File 'lib/remotedroid/query.rb', line 26 def cell_id() q(:cell_id) end |
#current_brightness ⇒ Object Also known as: brightness
20 21 22 |
# File 'lib/remotedroid/query.rb', line 20 def current_brightness() q(:current_brightness).to_i end |
#ip ⇒ Object
32 33 34 |
# File 'lib/remotedroid/query.rb', line 32 def ip() q(:ip) end |
#last_loc ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/remotedroid/query.rb', line 36 def last_loc() def self.alt() q(:last_loc_alt) end def self.latlon() q(:last_latlong) end def self.link() q(:last_loc_link) end def self.time() q(:last_loc_age_timestamp) end self end |
#location ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/remotedroid/query.rb', line 46 def location() r = @callback.query(@device, :location) return r if r.nil? or r.empty? or r[:coords].nil? r[:coords] = r[:coords].split(',') r[:time] = Time.parse(r[:time]) @locations << r @locations.shift if @locations.length > 1000 return r end |
#power_connected? ⇒ Boolean
59 60 61 62 |
# File 'lib/remotedroid/query.rb', line 59 def power_connected?() status = q(:power) status.downcase == 'on' if status end |
#take_picture ⇒ Object
64 65 66 |
# File 'lib/remotedroid/query.rb', line 64 def take_picture() @callback.query(@device, :'take-picture') end |
#take_screenshot ⇒ Object
68 69 70 |
# File 'lib/remotedroid/query.rb', line 68 def take_screenshot() @callback.query(@device, :'take-screenshot') end |
#volume(context = nil) ⇒ Object Also known as: vol
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/remotedroid/query.rb', line 72 def volume(context=nil) if context then q(context) else def self.alarm() q(:vol_alarm) end def self.bt_voice() q(:vol_bt_voice) end def self.call() q(:vol_call) end def self.music() q(:vol_music) end def self.notify() q(:vol_notif) end def self.system() q(:vol_system) end self end end |