Class: Rapuncel::Connection
- Inherits:
-
Object
- Object
- Rapuncel::Connection
- Defined in:
- lib/rapuncel/connection.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#ssl ⇒ Object
(also: #ssl?)
Returns the value of attribute ssl.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #auth? ⇒ Boolean
- #headers ⇒ Object
- #headers=(headers) ⇒ Object
-
#initialize(configuration = {}) ⇒ Connection
constructor
A new instance of Connection.
- #protocol ⇒ Object (also: #scheme)
- #url ⇒ Object
Constructor Details
#initialize(configuration = {}) ⇒ Connection
Returns a new instance of Connection.
6 7 8 |
# File 'lib/rapuncel/connection.rb', line 6 def initialize configuration = {} load_configuration configuration end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/rapuncel/connection.rb', line 3 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/rapuncel/connection.rb', line 3 def password @password end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/rapuncel/connection.rb', line 3 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/rapuncel/connection.rb', line 3 def port @port end |
#ssl ⇒ Object Also known as: ssl?
Returns the value of attribute ssl.
3 4 5 |
# File 'lib/rapuncel/connection.rb', line 3 def ssl @ssl end |
#user ⇒ Object
Returns the value of attribute user.
3 4 5 |
# File 'lib/rapuncel/connection.rb', line 3 def user @user end |
Instance Method Details
#auth? ⇒ Boolean
47 48 49 |
# File 'lib/rapuncel/connection.rb', line 47 def auth? !!user && !!password end |
#headers ⇒ Object
38 39 40 |
# File 'lib/rapuncel/connection.rb', line 38 def headers @headers.merge 'Accept' => 'text/xml', 'content-type' => 'text/xml' end |
#headers=(headers) ⇒ Object
32 33 34 35 36 |
# File 'lib/rapuncel/connection.rb', line 32 def headers= headers @headers = { 'User-Agent' => 'Rapuncel, Ruby XMLRPC Client' }.merge headers.stringify_keys end |
#protocol ⇒ Object Also known as: scheme
42 43 44 |
# File 'lib/rapuncel/connection.rb', line 42 def protocol ssl? ? 'https' : 'http' end |
#url ⇒ Object
10 11 12 |
# File 'lib/rapuncel/connection.rb', line 10 def url "#{protocol}://#{host}:#{port}#{path}" end |