Class: Sogger::Question

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/sogger/question.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#attributesObject

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

#publishedObject



30
31
32
# File 'lib/sogger/question.rb', line 30

def published
  @attributes[:published]
end

#tagsObject



26
27
28
# File 'lib/sogger/question.rb', line 26

def tags
  @attributes[:tags]
end

#titleObject



18
19
20
# File 'lib/sogger/question.rb', line 18

def title
  @attributes[:title]
end

#urlObject



22
23
24
# File 'lib/sogger/question.rb', line 22

def url
  @attributes[:url]
end