Skip to content

Instantly share code, notes, and snippets.

@michael
Created March 31, 2009 08:40
Show Gist options
  • Select an option

  • Save michael/88107 to your computer and use it in GitHub Desktop.

Select an option

Save michael/88107 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'ken'
# authentication is not needed for read-only access
Ken::Session.new('http://www.freebase.com', 'ma', 'xxxxx')
# fetch a resource
resource = Ken.get('/en/new_order') # => <Resource id="/en/new_order" name="New Order">
# let's inspect that resource
resource.views.each do |view|
view # => e.g. #<View type="/music/artist">
view.type # => e.g #<Type id="/music/artist" name="Musical Artist">
view.attributes
# => [#<Attribute property="/music/artist/home_page">,
#<Attribute property="/music/artist/genre">,
#<Attribute property="/music/artist/active_start">,
#<Attribute property="/music/artist/similar_artist">]
view.attributes.each do |att|
att.values
# e.g. => [ #<Resource id="/en/post-punk" name="Post-punk">,
#<Resource id="/en/synthpop" name="Synthpop">]
# e.g. => ["1980"]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment