Class: Upcoming::Category
- Inherits:
-
Object
- Object
- Upcoming::Category
- Defined in:
- lib/upcoming/category.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, name, description) ⇒ Category
constructor
A new instance of Category.
Constructor Details
#initialize(id, name, description) ⇒ Category
Returns a new instance of Category.
9 10 11 12 13 |
# File 'lib/upcoming/category.rb', line 9 def initialize(id, name, description) @id = id.to_i @name = name @description = description end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/upcoming/category.rb', line 7 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/upcoming/category.rb', line 7 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/upcoming/category.rb', line 7 def name @name end |
Class Method Details
.info(category_id) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/upcoming/category.rb', line 15 def self.info(category_id) Category.list.each do |cat| return cat if cat.id == category_id.to_i end nil end |
.list ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/upcoming/category.rb', line 23 def self.list categories = [] req = Upcoming::Request.new resp = req.send({:method => 'category.getList'}) doc = Document.new(resp.body) XPath.each(doc, '//category') do |el| categories << Category.new(el.attribute('id').value, el.attribute('name').value, el.attribute('description').value) end categories end |