Class: RemoteDroid::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/remotedroid/query.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#locationsObject

Returns the value of attribute locations.



5
6
7
# File 'lib/remotedroid/query.rb', line 5

def locations
  @locations
end

Class Method Details

.altObject



38
# File 'lib/remotedroid/query.rb', line 38

def self.alt()     q(:last_loc_alt)           end

.latlonObject



39
# File 'lib/remotedroid/query.rb', line 39

def self.latlon()  q(:last_latlong)           end


40
# File 'lib/remotedroid/query.rb', line 40

def self.link()    q(:last_loc_link)          end

.timeObject



41
# File 'lib/remotedroid/query.rb', line 41

def self.time()    q(:last_loc_age_timestamp) end

Instance Method Details

#airplane_mode_enabled?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/remotedroid/query.rb', line 12

def airplane_mode_enabled?()
  q(:airplane_mode_on).to_i > 0 
end

#batteryObject



16
17
18
# File 'lib/remotedroid/query.rb', line 16

def battery()      
  q(:battery).to_i
end

#cell_idObject Also known as: cell_tower



26
27
28
# File 'lib/remotedroid/query.rb', line 26

def cell_id()      
  q(:cell_id)
end

#current_brightnessObject Also known as: brightness



20
21
22
# File 'lib/remotedroid/query.rb', line 20

def current_brightness()      
  q(:current_brightness).to_i
end

#ipObject



32
33
34
# File 'lib/remotedroid/query.rb', line 32

def ip()      
  q(:ip)
end

#last_locObject



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

#locationObject



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

Returns:

  • (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_pictureObject



64
65
66
# File 'lib/remotedroid/query.rb', line 64

def take_picture()      
  @callback.query(@device, :'take-picture')
end

#take_screenshotObject



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