Class: Rapuncel::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/rapuncel/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#hostObject

Returns the value of attribute host.



3
4
5
# File 'lib/rapuncel/connection.rb', line 3

def host
  @host
end

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/rapuncel/connection.rb', line 3

def password
  @password
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/rapuncel/connection.rb', line 3

def path
  @path
end

#portObject

Returns the value of attribute port.



3
4
5
# File 'lib/rapuncel/connection.rb', line 3

def port
  @port
end

#sslObject Also known as: ssl?

Returns the value of attribute ssl.



3
4
5
# File 'lib/rapuncel/connection.rb', line 3

def ssl
  @ssl
end

#userObject

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

Returns:

  • (Boolean)


47
48
49
# File 'lib/rapuncel/connection.rb', line 47

def auth?
  !!user && !!password
end

#headersObject



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

#protocolObject Also known as: scheme



42
43
44
# File 'lib/rapuncel/connection.rb', line 42

def protocol
  ssl? ? 'https' : 'http'
end

#urlObject



10
11
12
# File 'lib/rapuncel/connection.rb', line 10

def url
  "#{protocol}://#{host}:#{port}#{path}"
end