Class: Cloudability::Budgets
- Inherits:
-
Object
- Object
- Cloudability::Budgets
- Includes:
- HTTParty
- Defined in:
- lib/cloudability/budgets.rb
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
Instance Method Summary collapse
-
#find_all ⇒ Object
Return all the budgets for the current account, and return as mash’s.
-
#find_by_id(id) ⇒ Object
Find a particular budget, based on its id, and return a mash.
-
#find_by_key(options = {}) ⇒ Object
Find a particular budget, based on a key, and return a mash.
-
#find_by_subject(subject) ⇒ Object
Find a particular budget, based on its subject, and return a mash.
-
#initialize(options = {}) ⇒ Budgets
constructor
A new instance of Budgets.
Constructor Details
#initialize(options = {}) ⇒ Budgets
Returns a new instance of Budgets.
9 10 11 12 |
# File 'lib/cloudability/budgets.rb', line 9 def initialize(={}) raise ArgumentError, "You must provide an auth token" if [:auth_token].nil? @auth_token = [:auth_token] end |
Instance Attribute Details
#auth_token ⇒ Object
Returns the value of attribute auth_token.
7 8 9 |
# File 'lib/cloudability/budgets.rb', line 7 def auth_token @auth_token end |
Instance Method Details
#find_all ⇒ Object
Return all the budgets for the current account, and return as mash’s.
15 16 17 |
# File 'lib/cloudability/budgets.rb', line 15 def find_all convert_to_mashes(get_budgets) end |
#find_by_id(id) ⇒ Object
Find a particular budget, based on its id, and return a mash.
20 21 22 |
# File 'lib/cloudability/budgets.rb', line 20 def find_by_id(id) find_all.select {|b| b.id == id}.first end |
#find_by_key(options = {}) ⇒ Object
Find a particular budget, based on a key, and return a mash.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cloudability/budgets.rb', line 34 def find_by_key(={}) case [:key] when :id budget = find_by_id([:value]) when :subject budget = find_by_subject([:value]) else raise ArgumentError, "You must provide a valid key." end end |
#find_by_subject(subject) ⇒ Object
Find a particular budget, based on its subject, and return a mash.
25 26 27 28 29 30 31 |
# File 'lib/cloudability/budgets.rb', line 25 def find_by_subject(subject) unless subject.length == 14 raise ArgumentError, "You must provide a valid subject such as 1234-5678-9101." end find_all.select {|b| b.subject == subject}.first end |