Class: RemoteDroid::Client
- Inherits:
-
Object
- Object
- RemoteDroid::Client
- Defined in:
- lib/remotedroid.rb
Instance Method Summary collapse
-
#battery ⇒ Object
– helpful methods —————–.
- #cell_tower ⇒ Object
- #control ⇒ Object
- #export(s) ⇒ Object
- #hotspot(state = nil) ⇒ Object
-
#initialize(host = '127.0.0.1') ⇒ Client
constructor
A new instance of Client.
- #invoke(s, *args) ⇒ Object
- #location ⇒ Object
- #photo ⇒ Object
- #query(id = nil) ⇒ Object
- #say(text) ⇒ Object
- #say_time ⇒ Object (also: #saytime)
- #screen(state = nil) ⇒ Object
- #screen_off ⇒ Object
- #screen_on ⇒ Object
- #store ⇒ Object
- #take_photo ⇒ Object
- #take_picture(ftp_src: nil, fileout: '.') ⇒ Object
- #torch ⇒ Object
- #update(key, val) ⇒ Object
- #vibrate ⇒ Object
Constructor Details
#initialize(host = '127.0.0.1') ⇒ Client
847 848 849 |
# File 'lib/remotedroid.rb', line 847 def initialize(host='127.0.0.1') @drb = OneDrb::Client.new host: host, port: '5777' end |
Instance Method Details
#battery ⇒ Object
– helpful methods —————–
882 883 884 |
# File 'lib/remotedroid.rb', line 882 def battery() query.battery end |
#cell_tower ⇒ Object
886 887 888 |
# File 'lib/remotedroid.rb', line 886 def cell_tower() query.cell_tower end |
#control ⇒ Object
851 852 853 |
# File 'lib/remotedroid.rb', line 851 def control @drb.control end |
#export(s) ⇒ Object
855 856 857 |
# File 'lib/remotedroid.rb', line 855 def export(s) @drb.export(s) end |
#hotspot(state = nil) ⇒ Object
890 891 892 |
# File 'lib/remotedroid.rb', line 890 def hotspot(state=nil) control.hotspot state end |
#invoke(s, *args) ⇒ Object
859 860 861 |
# File 'lib/remotedroid.rb', line 859 def invoke(s, *args) @drb.invoke(s, *args) end |
#location ⇒ Object
894 895 896 |
# File 'lib/remotedroid.rb', line 894 def location() query.location end |
#photo ⇒ Object
898 899 900 |
# File 'lib/remotedroid.rb', line 898 def photo() take_picture end |
#query(id = nil) ⇒ Object
863 864 865 866 867 868 869 870 |
# File 'lib/remotedroid.rb', line 863 def query(id=nil) return @drb.query unless id t = Time.now h = @drb.query(id) h.merge({latency: (Time.now - t).round(3)}) end |
#say(text) ⇒ Object
902 903 904 |
# File 'lib/remotedroid.rb', line 902 def say(text) control.speak_text text end |
#say_time ⇒ Object Also known as: saytime
906 907 908 |
# File 'lib/remotedroid.rb', line 906 def say_time() control.say_time end |
#screen(state = nil) ⇒ Object
912 913 914 |
# File 'lib/remotedroid.rb', line 912 def screen(state=nil) control.screen state end |
#screen_off ⇒ Object
920 921 922 |
# File 'lib/remotedroid.rb', line 920 def screen_off() screen :off end |
#screen_on ⇒ Object
916 917 918 |
# File 'lib/remotedroid.rb', line 916 def screen_on() screen :on end |
#store ⇒ Object
876 877 878 |
# File 'lib/remotedroid.rb', line 876 def store() @drb.store end |
#take_photo ⇒ Object
945 946 947 |
# File 'lib/remotedroid.rb', line 945 def take_photo() control.take_photo end |
#take_picture(ftp_src: nil, fileout: '.') ⇒ Object
924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 |
# File 'lib/remotedroid.rb', line 924 def take_picture(ftp_src: nil, fileout: '.') screen.on r = control.take_picture if ftp_src then # the sleep statement will be replaced in the near future, # but it's fine to demonstrate it works sleep 8 credentials, dir = ftp_src.match(/(ftp:\/\/[^\/]+)\/([^$]+)/).captures ftp = MyMediaFTP.new(credentials) ftp.cd dir filename = ftp.ls.sort_by {|x| x[:ctime]}.last[:name] ftp.cp filename, fileout end end |
#torch ⇒ Object
949 950 951 |
# File 'lib/remotedroid.rb', line 949 def torch() control.torch end |
#update(key, val) ⇒ Object
872 873 874 |
# File 'lib/remotedroid.rb', line 872 def update(key, val) @drb.update key.to_sym, val end |
#vibrate ⇒ Object
953 954 955 |
# File 'lib/remotedroid.rb', line 953 def vibrate control.vibrate end |