Skip to content

Instantly share code, notes, and snippets.

@steveklabnik
Created February 20, 2012 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveklabnik/1870730 to your computer and use it in GitHub Desktop.
Save steveklabnik/1870730 to your computer and use it in GitHub Desktop.
require 'hateoas'
class Maze
include Hateoas::MediaType
media_type "application/vnd.amundsen.maze+xml"
serialization :xml
element :maze,
:cell,
:code,
:error,
:collection,
:item,
:link,
:message,
:title,
:debug
attribute :href,
:rel,
:side,
:total,
:version
relation :collection,
:current,
:east,
:exit,
:maze,
:north,
:south,
:start,
:west
action :north,
:south,
:east,
:west,
:exit
end
maze = Maze.new("http://amundsen.com/examples/mazes/2d/five-by-five/")
puts "Let's navigate a maze!"
maze.transition("start")
action = ""
until action == "exit"
# puts maze.data #for debugging
puts "You can do these things:"
puts maze.actions.join(", ")
puts "What would you like to do?"
action = gets.chomp
maze.transition(action)
end
puts "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment