Class: SharpAquosRemoteControl
- Inherits:
-
Object
- Object
- SharpAquosRemoteControl
- Defined in:
- lib/sharp_aquos_remote_control.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #analog_channel(value) ⇒ Object
- #channel_down ⇒ Object
- #channel_up ⇒ Object
- #digital_channel(value) ⇒ Object
-
#initialize(hostname = "192.168.2.188", port = 10002, username = nil, password = nil) ⇒ SharpAquosRemoteControl
constructor
A new instance of SharpAquosRemoteControl.
- #input(value) ⇒ Object
- #input? ⇒ Boolean
- #mute ⇒ Object
- #muted? ⇒ Boolean
- #off ⇒ Object
- #off? ⇒ Boolean
- #on ⇒ Object
- #on? ⇒ Boolean
- #request(command) ⇒ Object
- #unmute ⇒ Object
- #volume(level) ⇒ Object
- #volume? ⇒ Boolean
Constructor Details
#initialize(hostname = "192.168.2.188", port = 10002, username = nil, password = nil) ⇒ SharpAquosRemoteControl
Returns a new instance of SharpAquosRemoteControl.
9 10 11 12 13 14 |
# File 'lib/sharp_aquos_remote_control.rb', line 9 def initialize(hostname = "192.168.2.188", port = 10002, username = nil, password = nil) @hostname = hostname @port = port @username = username @password = password end |
Instance Attribute Details
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
4 5 6 |
# File 'lib/sharp_aquos_remote_control.rb', line 4 def hostname @hostname end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
7 8 9 |
# File 'lib/sharp_aquos_remote_control.rb', line 7 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/sharp_aquos_remote_control.rb', line 5 def port @port end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
6 7 8 |
# File 'lib/sharp_aquos_remote_control.rb', line 6 def username @username end |
Instance Method Details
#analog_channel(value) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/sharp_aquos_remote_control.rb', line 16 def analog_channel(value) return "Analog Channels are limited to 2 through 69" if value < 2 || value > 69 new_channel = value.to_s.rjust(2, "0") request "DCCH" + new_channel + " \x0D" end |
#channel_down ⇒ Object
32 33 34 |
# File 'lib/sharp_aquos_remote_control.rb', line 32 def channel_down request "CHUP0 \x0D" end |
#channel_up ⇒ Object
36 37 38 |
# File 'lib/sharp_aquos_remote_control.rb', line 36 def channel_up request "CHUP0 \x0D" end |
#digital_channel(value) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/sharp_aquos_remote_control.rb', line 23 def digital_channel(value) first = (value.to_s.split(".")[0]).to_i second = (value.to_s.split(".")[1] || 0).to_i return "Analog Channels are limited to 1 through 99.99" if first < 1 || first > 99 || second < 0 || second > 99 new_channel = first.to_s.rjust(2, "0") + second.to_s.rjust(2, "0") request "DA2P" + new_channel + "\x0D" end |
#input(value) ⇒ Object
40 41 42 43 |
# File 'lib/sharp_aquos_remote_control.rb', line 40 def input(value) return "Inputs are limited to 1 through 9" if value < 1 || value > 9 request("IAVD" + value.to_s + " \x0D") end |
#input? ⇒ Boolean
45 46 47 |
# File 'lib/sharp_aquos_remote_control.rb', line 45 def input? request "IAVD? \x0D" end |
#mute ⇒ Object
49 50 51 |
# File 'lib/sharp_aquos_remote_control.rb', line 49 def mute request "MUTE1 \x0D" end |
#muted? ⇒ Boolean
57 58 59 |
# File 'lib/sharp_aquos_remote_control.rb', line 57 def muted? request("MUTE? \x0D") == "1" end |
#off ⇒ Object
61 62 63 |
# File 'lib/sharp_aquos_remote_control.rb', line 61 def off request "POWR0 \x0D" end |
#off? ⇒ Boolean
65 66 67 |
# File 'lib/sharp_aquos_remote_control.rb', line 65 def off? request("POWR? \x0D") == "0" end |
#on ⇒ Object
69 70 71 |
# File 'lib/sharp_aquos_remote_control.rb', line 69 def on request "POWR1 \x0D" end |
#on? ⇒ Boolean
73 74 75 |
# File 'lib/sharp_aquos_remote_control.rb', line 73 def on? request("POWR? \x0D") == "1" end |
#request(command) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/sharp_aquos_remote_control.rb', line 88 def request(command) response = Socket.tcp(@hostname, @port) do |socket| socket.write command socket.recv 1024 end response.strip end |
#unmute ⇒ Object
53 54 55 |
# File 'lib/sharp_aquos_remote_control.rb', line 53 def unmute request "MUTE2 \x0D" end |
#volume(level) ⇒ Object
77 78 79 80 81 82 |
# File 'lib/sharp_aquos_remote_control.rb', line 77 def volume(level) return "Volume is limited to 0 through 60" if level < 0 || level > 60 new_volume = level.to_s.rjust(2, "0") request("VOLM" + new_volume + " \x0D") end |
#volume? ⇒ Boolean
84 85 86 |
# File 'lib/sharp_aquos_remote_control.rb', line 84 def volume? request("VOLM? \x0D").to_i end |