Class: Wordpressto::WordpressPostCollection

Inherits:
Base
  • Object
show all
Defined in:
lib/wordpressto.rb

Instance Method Summary collapse

Methods inherited from Base

#conn, #initialize

Constructor Details

This class inherits a constructor from Wordpressto::Base

Instance Method Details

#find(qid, options = { }) ⇒ Object



120
121
122
123
124
125
126
127
128
129
# File 'lib/wordpressto.rb', line 120

def find(qid, options = { })
  if qid.is_a?(Array)
    qid.collect { |sqid| find(sqid) }
  elsif qid == :recent
    find_recent(options)
  else
    post = conn.get_post(qid)
    WordpressPost.new(post, :conn => conn)
  end
end

#find_recent(options = { }) ⇒ Object



114
115
116
117
118
# File 'lib/wordpressto.rb', line 114

def find_recent(options = { })
  options = { :limit => 10 }.merge(options)
  posts = conn.get_recent_posts(options[:limit])
  posts.collect { |post|  WordpressPost.new(post, :conn => conn) }
end

#new(attributes = { }) ⇒ Object



131
132
133
# File 'lib/wordpressto.rb', line 131

def new(attributes = { })
  WordpressPost.new(attributes, :conn => conn)
end