Class: JAPI::Category
- Inherits:
-
Object
- Object
- JAPI::Category
- Defined in:
- lib/japi/category.rb
Overview
Category object with associated clues and a title.
Instance Method Summary collapse
-
#category_id ⇒ Fixnum
Id of the category.
-
#clues ⇒ Array<Clue>
Array of clues associated with a Category.
-
#clues_count ⇒ Fixnum
Amount of clues associated with this category.
-
#initialize(options = {}) ⇒ Category
constructor
A new instance of Category.
-
#title ⇒ String
Title of the category.
Constructor Details
#initialize(options = {}) ⇒ Category
Returns a new instance of Category.
11 12 13 14 15 16 |
# File 'lib/japi/category.rb', line 11 def initialize( = {}) = if ["clues"] ["clues"] = ["clues"].map { |clue| Clue.new(clue) } end end |
Instance Method Details
#category_id ⇒ Fixnum
Returns id of the category.
24 25 26 |
# File 'lib/japi/category.rb', line 24 def category_id ["id"] end |
#clues ⇒ Array<Clue>
Returns array of clues associated with a Category.
34 35 36 37 |
# File 'lib/japi/category.rb', line 34 def clues return ["clues"] unless ["clues"].nil? ["clues"] = Trebek.category(category_id).clues end |
#clues_count ⇒ Fixnum
Returns amount of clues associated with this category.
29 30 31 |
# File 'lib/japi/category.rb', line 29 def clues_count ["clues_count"] end |
#title ⇒ String
Returns title of the category.
19 20 21 |
# File 'lib/japi/category.rb', line 19 def title ["title"] end |