examples/hilo/source/hilo.rb in trellis-0.0.1 vs examples/hilo/source/hilo.rb in trellis-0.0.2
- old
+ new
@@ -5,19 +5,18 @@
module HiLo
class HiLoGame < Application
home :start
- pages :guess, :game_over
+ logger.level = DEBUG
end
class Start < Page
pages :guess
def on_select
- @guess.target = rand(10);
- return @guess
+ @guess.initialize_target
end
end
class Guess < Page
pages :game_over
@@ -35,16 +34,17 @@
end
next_page
end
- def target=(value)
- @target, @count, @message = value, 0, ''
+ def initialize_target
+ @target, @count, @message = rand(9) + 1, 0, ''
+ self
end
end
class GameOver < Page
- attr_accessor :count
+ persistent :count
end
web_app = HiLoGame.new
web_app.start 3001 if __FILE__ == $PROGRAM_NAME
end