Class: Sently::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/sently/configuration.rb

Constant Summary collapse

OPTIONS =
[:username, :password,
:http_open_timeout, :http_read_timeout,
:protocol, :host, :port, :secure,
:production_environment].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



21
22
23
24
25
26
27
28
29
# File 'lib/sently/configuration.rb', line 21

def initialize
  @secure                   = false
  @host                     = 'sent.ly'
  @http_open_timeout        = 10
  @http_read_timeout        = 10
  @production_environment   = true
  @sms_uri                  = '/command/sendsms'
  @port                     = default_port
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



15
16
17
# File 'lib/sently/configuration.rb', line 15

def host
  @host
end

#http_open_timeoutObject

Returns the value of attribute http_open_timeout.



13
14
15
# File 'lib/sently/configuration.rb', line 13

def http_open_timeout
  @http_open_timeout
end

#http_read_timeoutObject

Returns the value of attribute http_read_timeout.



14
15
16
# File 'lib/sently/configuration.rb', line 14

def http_read_timeout
  @http_read_timeout
end

#passwordObject

Returns the value of attribute password.



10
11
12
# File 'lib/sently/configuration.rb', line 10

def password
  @password
end

#portObject

Returns the value of attribute port.



16
17
18
# File 'lib/sently/configuration.rb', line 16

def port
  @port
end

#production_environmentObject

Returns the value of attribute production_environment.



17
18
19
# File 'lib/sently/configuration.rb', line 17

def production_environment
  @production_environment
end

#secureObject Also known as: secure?

Returns the value of attribute secure.



12
13
14
# File 'lib/sently/configuration.rb', line 12

def secure
  @secure
end

#sms_uriObject

Returns the value of attribute sms_uri.



11
12
13
# File 'lib/sently/configuration.rb', line 11

def sms_uri
  @sms_uri
end

#usernameObject

Returns the value of attribute username.



9
10
11
# File 'lib/sently/configuration.rb', line 9

def username
  @username
end

Instance Method Details

#[](option) ⇒ Object



31
32
33
# File 'lib/sently/configuration.rb', line 31

def [](option)
  send(option)
end

#merge(hash) ⇒ Object



41
42
43
# File 'lib/sently/configuration.rb', line 41

def merge(hash)
  to_hash.merge(hash)
end

#protocolObject



49
50
51
52
53
54
55
# File 'lib/sently/configuration.rb', line 49

def protocol
  if secure?
    'https'
  else
    'http'
  end
end

#to_hashObject



35
36
37
38
39
# File 'lib/sently/configuration.rb', line 35

def to_hash
  OPTIONS.inject({}) do |hash, option|
    hash.merge(option.to_sym => send(option))
  end
end