Class: RTransmission::Session
- Inherits:
-
Object
- Object
- RTransmission::Session
- Defined in:
- lib/rtransmission/session.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
- #blocklist_update ⇒ Object
-
#initialize(client) ⇒ Session
constructor
A new instance of Session.
- #port_test ⇒ Object
- #shutdown ⇒ Object
- #stats ⇒ Object
Constructor Details
#initialize(client) ⇒ Session
77 78 79 |
# File 'lib/rtransmission/session.rb', line 77 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/rtransmission/session.rb', line 7 def client @client end |
Class Method Details
.attribute(rpc_name, args = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rtransmission/session.rb', line 9 def self.attribute(rpc_name, args = {}) name = args[:name] || RTransmission::Client.rpc_name_to_ruby_name(rpc_name) self.send :define_method, name.to_s do request = RTransmission::Request.new('session-get', {}, 'Session.' + name.to_s) do |arguments| value = arguments[rpc_name] RTransmission::Type.unmap(value, args[:type]) end @client.call(request) end if args[:writeable] == true self.send :define_method, name.to_s.gsub('?', '') + '=' do |value| rpc_value = RTransmission::Type.unmap(value, args[:type]) request = RTransmission::Request.new('session-set', {rpc_name => rpc_value}, 'Session.' + name.to_s + '=') do value end @client.call(request) end end end |
Instance Method Details
#blocklist_update ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/rtransmission/session.rb', line 89 def blocklist_update request = RTransmission::Request.new('blocklist-update', {}, 'Session.blocklist_update') do |arguments| arguments['blocklist-size'] end @client.call(request) end |
#port_test ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/rtransmission/session.rb', line 97 def port_test request = RTransmission::Request.new('port-test', {}, 'Session.port_test') do |arguments| arguments['port-is-open'] end @client.call(request) end |
#shutdown ⇒ Object
105 106 107 |
# File 'lib/rtransmission/session.rb', line 105 def shutdown @client.call(RTransmission::Request.new('session-close', {}, 'Session.shutdown')) end |
#stats ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/rtransmission/session.rb', line 81 def stats request = RTransmission::Request.new('session-stats', {}, 'Session.stats') do |arguments| RTransmission::Types::Stats.unmap(arguments) end @client.call(request) end |