Class: EasyPing::Config

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

Constant Summary collapse

OPTIONS =
[:app_id, :channel, :currency]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Config

Returns a new instance of Config.



7
8
9
10
11
# File 'lib/easy_ping/config.rb', line 7

def initialize(options)
  options.each do |key, val|
    self.send("#{key}=", val) if self.respond_to?("#{key}=")
  end
end

Instance Attribute Details

#api_baseObject

Returns the value of attribute api_base.



5
6
7
# File 'lib/easy_ping/config.rb', line 5

def api_base
  @api_base
end

#api_keyObject

Returns the value of attribute api_key.



5
6
7
# File 'lib/easy_ping/config.rb', line 5

def api_key
  @api_key
end

Instance Method Details

#to_optionsObject



17
18
19
20
21
22
# File 'lib/easy_ping/config.rb', line 17

def to_options
  options = {}
  values = OPTIONS.map { |key| self.send key }
  OPTIONS.zip(values) { |k,v| options[k.to_s] = v }
  options
end