Class: BillHicks::Category
Overview
Category item response structure:
{
code: "...", # ':category_code' in Catalog response.
description: "..." # ':category_description' in Catalog response.
}
Class Method Summary collapse
Instance Method Summary collapse
-
#all ⇒ Object
Returns an array of hashes with category details.
-
#initialize(options = {}) ⇒ Category
constructor
A new instance of Category.
Methods inherited from Base
Constructor Details
#initialize(options = {}) ⇒ Category
Returns a new instance of Category.
10 11 12 13 |
# File 'lib/bill_hicks/category.rb', line 10 def initialize( = {}) requires!(, :username, :password) = end |
Class Method Details
.all(options = {}) ⇒ Object
15 16 17 18 |
# File 'lib/bill_hicks/category.rb', line 15 def self.all( = {}) requires!(, :username, :password) new().all end |
Instance Method Details
#all ⇒ Object
Returns an array of hashes with category details.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bill_hicks/category.rb', line 21 def all categories = [] # Categories are listed in catalog csv, so fetch that. catalog = Catalog.all() catalog.each do |item| categories << { code: item[:category_code], description: item[:category_description] } end categories.uniq! { |c| c[:description] } categories.sort_by! { |c| c[:description] } categories end |