Class: DeviceCloud::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/device_cloud/config.rb

Constant Summary collapse

DEFAULT_USERNAME =
""
DEFAULT_PASSWORD =
""
DEFAULT_HOST =
"login.etherios.com"
DEFAULT_PROTOCOL =
"https"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Config

Returns a new instance of Config.



10
11
12
13
# File 'lib/device_cloud/config.rb', line 10

def initialize(args)
  args = Hash[*args.map { |k, v| [k.to_s, v] }.flatten] unless args.nil?
  init_with args
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



8
9
10
# File 'lib/device_cloud/config.rb', line 8

def host
  @host
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/device_cloud/config.rb', line 8

def password
  @password
end

#protocolObject

Returns the value of attribute protocol.



8
9
10
# File 'lib/device_cloud/config.rb', line 8

def protocol
  @protocol
end

#usernameObject

Returns the value of attribute username.



8
9
10
# File 'lib/device_cloud/config.rb', line 8

def username
  @username
end

Instance Method Details

#init_with(args) ⇒ Object

YAML Initializer



16
17
18
19
20
21
# File 'lib/device_cloud/config.rb', line 16

def init_with(args)
  @username = args["username"] || DEFAULT_USERNAME
  @password = args["password"] || DEFAULT_PASSWORD
  @host = args["host"] || DEFAULT_HOST
  @protocol = args["protocol"] || DEFAULT_PROTOCOL
end