Module: KodiClient::Extensions::Chainable
- Included in:
- KodiClient, Client
- Defined in:
- lib/kodi_client/extensions/chainable.rb
Overview
Offers methods like connect, auth and tls to be chained together
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#auth(username, password) ⇒ Client
sets username and password if required.
-
#connect(ip, port) ⇒ Client
Creates a new Client instance and sets the given ip and port to connect to it.
-
#use_tls(enabled: true) ⇒ Client
enables/disables the use of TLS.
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
8 9 10 |
# File 'lib/kodi_client/extensions/chainable.rb', line 8 def client @client end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/kodi_client/extensions/chainable.rb', line 8 def @options end |
Instance Method Details
#auth(username, password) ⇒ Client
sets username and password if required
26 27 28 29 30 |
# File 'lib/kodi_client/extensions/chainable.rb', line 26 def auth(username, password) raise ArgumentError, 'username or password can\'t be nil.' if username.nil? || password.nil? (->() { .with_auth(username, password) }) end |
#connect(ip, port) ⇒ Client
Creates a new Client instance and sets the given ip and port to connect to it
15 16 17 18 19 20 |
# File 'lib/kodi_client/extensions/chainable.rb', line 15 def connect(ip, port) raise ArgumentError, 'ip or port can\'t be nil.' if ip.nil? || port.nil? @client = KodiClient::Client.new (->() { .with_connection(ip, port) }) end |
#use_tls(enabled: true) ⇒ Client
enables/disables the use of TLS
35 36 37 |
# File 'lib/kodi_client/extensions/chainable.rb', line 35 def use_tls(enabled: true) (->() { .with_tls(enabled) }) end |