Class: Mirrored::Date
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#date ⇒ Object
Returns the value of attribute date.
Class Method Summary collapse
-
.find(*args) ⇒ Object
Does all the hard work finding the dates you have posted and how many posts on those days.
-
.new_from_xml(xml) ⇒ Object
:nodoc:.
Methods inherited from Base
api_url, connection, establish_connection, remove_connection, service, valid_service?
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
24 25 26 |
# File 'lib/mirrored/date.rb', line 24 def count @count end |
#date ⇒ Object
Returns the value of attribute date.
24 25 26 |
# File 'lib/mirrored/date.rb', line 24 def date @date end |
Class Method Details
.find(*args) ⇒ Object
Does all the hard work finding the dates you have posted and how many posts on those days.
Usage:
Mirrored::Date.find(:all) # => finds all dates you have posted with counts for each day
Mirrored::Date.find(:all, :tag => 'ruby') # => finds all dates you have posted something tagged ruby with counts for each day
15 16 17 18 19 20 21 22 |
# File 'lib/mirrored/date.rb', line 15 def self.find(*args) raise ArgumentError, "First argument must be symbol (:all)" unless args.first.kind_of?(Symbol) params = args. params = params == {} ? nil : params doc = Hpricot::XML(connection.get("posts/dates", params)) (doc/:date).inject([]) { |elements, el| elements << new_from_xml(el); elements } end |
.new_from_xml(xml) ⇒ Object
:nodoc:
3 4 5 6 7 8 |
# File 'lib/mirrored/date.rb', line 3 def self.new_from_xml(xml) #:nodoc: d = Date.new d.date = ::Date.parse((xml)['date']) d.count = (xml)['count'] d end |