Class: Sogger::Question
- Inherits:
-
Object
- Object
- Sogger::Question
- Includes:
- Comparable
- Defined in:
- lib/sogger/question.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(attributes = {}) ⇒ Question
constructor
A new instance of Question.
- #published ⇒ Object
- #tags ⇒ Object
- #title ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Question
Returns a new instance of Question.
6 7 8 |
# File 'lib/sogger/question.rb', line 6 def initialize(attributes = {}) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/sogger/question.rb', line 4 def attributes @attributes end |
Class Method Details
.from_xml(xml_element) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/sogger/question.rb', line 10 def self.from_xml(xml_element) attributes = { :title => xml_element.css('title').text, :url => xml_element.css('id').text, :tags => xml_element.css('category').map{|c| c['term']}, :published => DateTime.parse(xml_element.css('published').text) } new attributes end |
Instance Method Details
#<=>(other) ⇒ Object
34 35 36 |
# File 'lib/sogger/question.rb', line 34 def <=>(other) other.published <=> published end |
#published ⇒ Object
30 31 32 |
# File 'lib/sogger/question.rb', line 30 def published @attributes[:published] end |
#tags ⇒ Object
26 27 28 |
# File 'lib/sogger/question.rb', line 26 def @attributes[:tags] end |
#title ⇒ Object
18 19 20 |
# File 'lib/sogger/question.rb', line 18 def title @attributes[:title] end |
#url ⇒ Object
22 23 24 |
# File 'lib/sogger/question.rb', line 22 def url @attributes[:url] end |