Class: RemoteDroid::Control

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

Instance Method Summary collapse

Constructor Details

#initialize(dev = nil, deviceid: dev, remote_url: nil, debug: false) ⇒ Control

Returns a new instance of Control.



580
581
582
583
584
# File 'lib/remotedroid.rb', line 580

def initialize(dev=nil, deviceid: dev, remote_url: nil, debug: false)
  
  @deviceid, @remote_url, @debug = deviceid, remote_url, debug
  @torch = Torch.new(self)
end

Instance Method Details

#bluetoothObject



586
587
588
# File 'lib/remotedroid.rb', line 586

def bluetooth()
  @bluetooth
end

#camera_flash_light(options = {}) ⇒ Object



590
591
592
# File 'lib/remotedroid.rb', line 590

def camera_flash_light(options={})
  http_exec 'camera-flash-light', options
end

#http_exec(command, options = {}) ⇒ Object



594
595
596
597
598
599
600
601
602
603
604
605
606
# File 'lib/remotedroid.rb', line 594

def http_exec(command, options={})
  
  url = "https://trigger.macrodroid.com/%s/%s" % [@deviceid, command]
  
  if options and options.any? then
    h = options
    url += '?' + \
        URI.escape(h.map {|key,value| "%s=%s" % [key, value]}.join('&'))
  end
  
  s = open(url).read
  
end

#location(options = {}) ⇒ Object



608
609
610
# File 'lib/remotedroid.rb', line 608

def location(options={})
  http_exec 'location'
end

#method_missing2(method_name, *args) ⇒ Object



658
659
660
# File 'lib/remotedroid.rb', line 658

def method_missing2(method_name, *args)
  http_exec(method_name, args.first)
end

#say_current_time(options = {}) ⇒ Object Also known as: say_time



612
613
614
# File 'lib/remotedroid.rb', line 612

def say_current_time(options={})
  http_exec 'say-current-time'
end

#share_location(options = {}) ⇒ Object



618
619
620
# File 'lib/remotedroid.rb', line 618

def share_location(options={})
  http_exec 'share-location'
end

#speak_text(obj) ⇒ Object Also known as: say



622
623
624
625
626
627
628
629
630
631
632
# File 'lib/remotedroid.rb', line 622

def speak_text(obj)
  
  options = case obj
  when String
    {text: obj}
  when Hash
    obj
  end

  http_exec 'speak-text', options
end

#toast(options = {}) ⇒ Object



636
637
638
# File 'lib/remotedroid.rb', line 636

def toast(options={})
  http_exec :toast, options
end

#torch(options = {}) ⇒ Object



640
641
642
# File 'lib/remotedroid.rb', line 640

def torch(options={})
  http_exec :torch 
end

#vibrate(options = {}) ⇒ Object



644
645
646
# File 'lib/remotedroid.rb', line 644

def vibrate(options={})
  http_exec :vibrate
end

#write(s) ⇒ Object Also known as: export



649
650
651
652
653
654
# File 'lib/remotedroid.rb', line 649

def write(s)
        
  MacroDroid.new(RD_MACROS, deviceid: @deviceid, 
                 remote_url: @remote_url, debug: @debug).export s
  
end