Skip to content

forrestc/ruby-factual

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample Usage

A block of code is worth a thousand words.

require 'rubygems'
gem 'ruby-factual'
require 'factual'

api = Factual::Api.new(:api_key => "<YOUR_FACTUAL_API_KEY>", :version => 2)

# get table and its metadata
# table metadata: name, description, rating, source, creator, created_at,
#                 updated_at, total_row_count, geo_enabled, downloadable, 
#                 fields (array of hash)
table = api.get_table("g9R1u2")
puts table.name, table.creator

# read rows after filtering and sorting
table.filter(:two_letter_abbrev => "CA").sort(:state => -1).page(1, :size => 5).each_row do |state_info|

  # read facts
  # fact attributes: value, subject_key, field_ref, field (hash)
  fact = state_info["state"]
  puts fact.value, fact.subject_key

  # write facts
  if fact.input("Kalifornia", :source => "source", :comment => "comment")
    puts "inputted"
  end
end

About

Ruby library for Factual API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages