- 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
3 comments:
Hi,
I was trying to gem install diggr, but it keep saying "Failed to build gem native extension".
I'm new to RoR, so unable to get to the solution. Can you help me with that please.
Thanks
Sanjay -
Are you attempting to build other gems along with diggr? diggr does not have any native extensions nor does any of it dependencies. Not exactly sure why you would be running into this error. Are you doing the following to install it:
sudo gem install diggr
Hey Drew,
No I'm not trying to build any other gem. I'm just trying to install diggr. I'm running windows vista, and simply doing a gem install diggr. As per the requirements, I have json-1.1.3, rails-2.2.1 and it's dependencies.
Not quite sure why this is happening. Any suggestions ??
Post a Comment