Created
March 31, 2009 08:40
-
-
Save michael/88107 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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