Class: Valuefirst::Config
- Inherits:
-
Object
- Object
- Valuefirst::Config
- Defined in:
- lib/valuefirst/config.rb
Instance Attribute Summary collapse
-
#default_sender ⇒ Object
Returns the value of attribute default_sender.
-
#password ⇒ Object
Returns the value of attribute password.
-
#url ⇒ Object
Returns the value of attribute url.
-
#username ⇒ Object
Returns the value of attribute username.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Config
constructor
A new instance of Config.
- #validate ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 10 11 |
# File 'lib/valuefirst/config.rb', line 5 def initialize(opts = {}) @username = opts[:username] @password = opts[:password] @default_sender = opts[:default_sender] @url = opts[:url] || "http://api.myvaluefirst.com/psms/servlet/psms.Eservice2" @version = opts[:version] || '1.2' end |
Instance Attribute Details
#default_sender ⇒ Object
Returns the value of attribute default_sender.
3 4 5 |
# File 'lib/valuefirst/config.rb', line 3 def default_sender @default_sender end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/valuefirst/config.rb', line 3 def password @password end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/valuefirst/config.rb', line 3 def url @url end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/valuefirst/config.rb', line 3 def username @username end |
#version ⇒ Object
Returns the value of attribute version.
3 4 5 |
# File 'lib/valuefirst/config.rb', line 3 def version @version end |
Instance Method Details
#validate ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/valuefirst/config.rb', line 13 def validate errors = [] errors << "Invalid username" if @username.nil? || @username.empty? errors << "Invalid password" if @password.nil? || @password.empty? errors << "API version not supported" unless @version == '1.2' unless errors.empty? raise ArgumentError, "#{errors.join(', ')}" end end |