Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Snafu is a Ruby interface for the Glitch API. Please see http://api.glitch.com for more information.

branch: master

GlitchTime now returns a 1-based day of week, day of year, day of mon…

…th, and month of year

GlitchTime now returns a 1-based day of week, day of year, day of
month, and month of year (i.e. the first day of the week is 1); the
year is still 0-based (year 0 being the the first year of the game)
latest commit f86603cf20
Jeff Browning authored June 25, 2012
Octocat-spinner-32 lib GlitchTime now returns a 1-based day of week, day of year, day of mon… June 25, 2012
Octocat-spinner-32 spec GlitchTime now returns a 1-based day of week, day of year, day of mon… June 25, 2012
Octocat-spinner-32 .gitignore Many changes June 17, 2012
Octocat-spinner-32 CHANGELOG.textile GlitchTime now returns a 1-based day of week, day of year, day of mon… June 25, 2012
Octocat-spinner-32 Gemfile initial commit November 27, 2011
Octocat-spinner-32 Guardfile initial commit November 27, 2011
Octocat-spinner-32 LICENSE initial commit November 27, 2011
Octocat-spinner-32 README.textile GlitchTime now returns a 1-based day of week, day of year, day of mon… June 25, 2012
Octocat-spinner-32 Rakefile initial commit November 27, 2011
Octocat-spinner-32 snafu.gemspec Updated gemspec June 17, 2012
README.textile

Snafu

Snafu is a Ruby gem that provides an interface to the API for Glitch, a browser-based MMO created by Tiny Speck.

API Support

Currently Supported

  • In-Game Time & Date (See the GlitchTime class for more info)
  • Giants
    • giants.list (Snafu::Giants#get_giants)
  • Locations
    • locations.getHubs (Snafu::Locations#get_hubs)
    • locations.getStreets (Snafu::Locations#get_hub)
    • locations.streetInfo (Snafu::Locations#get_street)

Not Yet Supported

  • Achievements
  • Auctions
  • Avatar
  • Players
  • Skills

Usage

To get started, instantiate the client with either no options or with the OAuth token of an authenticated user if ‘identity’ scope or higher is required.

    snafu = Snafu.new(:oauth_token => "your-oauth-token")

Snafu currently does not support Glitch’s OAuth authentication. There are other gems that support authenticating with Glitch such as OmniAuth.

In-Game Time & Date

Note that the hour, minute, day of week, day of year, and day of month are all zero-based.

To get the current in-game date and time:

    current_time = snafu.glitch_time
    current_time.year
    => 20
    current_time.month
    => "Spork"
    current_time.day
    => "Hairday"

Giants

You can get a list of all giants:

    # giants.list
    giants = snafu.get_giants
    giants.first.name
    => "Alph"

Or, if you supply read-level OAuth token, you can see the user’s favor with all giants:

    # giants.getFavor
    giants = snafu.get_giants_favor
    giants.first.name
    => "Alph"
    giants.first.cur_favor
    => 323

Locations

All locations.* methods are supported. Each method returns a Ruby object representing the returned data.

    # locations.*
    hubs = snafu.get_hubs # "locations.getHubs"
    hub = snafu.get_hub(hub_id) # "locations.getStreets"
    street = snafu.get_street(street_tsid) # "locations.streetInfo"

Achievements

    achievements = snafu.get_achievements # "achievements.listAll"
    achievements.first.name
    => "1-Star Cuisinartist"
    achievements.first.desc
    => "Whipped up 11 meals with an Awesome Pot"

Manual Method Calls

You can also receive raw data from the Glitch API by passing any method name into #call and supplying any required parameters via an options hash. This returns a Hash representation of the JSON returned by Glitch.

For example, to manually call the Glitch calendar.getholidays method:

    snafu.call("calendar.getHolidays")
    => {
    =>   "ok"=>1,
    =>   "days"=>
    =>   [{"month"=>1, "day"=>5, "name"=>"AlphCon"},
    =>    {"month"=>2, "day"=>2, "name"=>"Lemadan"},
    =>    {"month"=>3, "day"=>3, "name"=>"Pot Twoday"},
    =>    {"month"=>4, "day"=>2, "name"=>"Root"},
    =>    {"month"=>4, "day"=>3, "name"=>"Root"},
    =>    {"month"=>4, "day"=>4, "name"=>"Root"},
    =>    {"month"=>4, "day"=>11, "name"=>"Sprinkling"},
    =>    {"month"=>6, "day"=>17, "name"=>"Croppaday"},
    =>    {"month"=>7, "day"=>1, "name"=>"Belabor Day"},
    =>    {"month"=>8, "day"=>37, "name"=>"Zilloween"},
    =>    {"month"=>11, "day"=>11, "name"=>"Recurse Eve"}]
    => }

    snafu.call("locations.getStreets", :hub_id => 27)
    => {
    =>   "ok"=>1,
    =>   "hub_id"=>"27",
    =>   "name"=>"Ix",
    =>   "streets"=>
    =>   {
    =>     "LM416LNIKVLM1"=>{"name"=>"Baby Steppes"},
    =>     "LM413SQ6LRN58"=>{"name"=>"East Spice"},
    =>     "LM410QQ0CHARO"=>{"name"=>"Flipside"},
    =>     "LM4115NJ46G8M"=>{"name"=>"Groddle Ladder"},
    =>     "LM4109NI2R640"=>{"name"=>"Guillermo Gamera Way"},
    =>     "LM410TMR0S2S1"=>{"name"=>"Ruta Asuncion"},
    =>     "LM413RQ6LRG9N"=>{"name"=>"West Spice"}
    =>   }
    => }

Credits

Jeff Browning – Original author
Lee Jensen – Contributions to GlitchTime

Something went wrong with that request. Please try again.