- Docs
- Source
Here are a few simple examples:
diggr = Diggr::API.new
# retrieve a single user by user name and print the number of profile views
user = diggr.user("johndoe").fetch
puts user.profileviews
# iterator over the most recent 10 stories (default return size) and print their titles
diggr.stories.each do |story|
puts story.title
end
# print the title of the 3 most recent hot stories
diggr.stories.hot.options(:count => 3).each do |story|
puts story.title
end
# build an array of stories whos title contains "foo"
diggr.stories.inject([]) do |array,story|
array << story if story.title =~ /foo/
array
end
# print the title of the 2nd and 3rd most recent stories
diggr.stories.options(:count => 2, :offset => 2).each do |story|
puts story.title
end