Permalink
Browse files

Bring examples up-to-date with latest commits

  • Loading branch information...
1 parent 2cb116e commit 8ca9aba1e68e43005b0bf43f42c85109e0a2e841 @mneumann committed Jan 6, 2010
Showing with 17 additions and 19 deletions.
  1. +8 −7 examples/arc_challenge2.rb
  2. +0 −3 examples/cheese_task.rb
  3. +9 −9 examples/demo/counter.rb
View
@@ -9,27 +9,28 @@
$LOAD_PATH.unshift "../lib"
require 'rubygems'
require 'wee'
-require "wee/conversation"
class Wee::IO
def initialize(component)
@component = component
end
def ask
- @component.display do |r|
- text = nil
- r.text_input.callback {|t| text = t}
- r.submit_button.callback { answer(text) }.value("Enter")
+ @component.call_inline do |r|
+ r.form do
+ text = nil
+ r.text_input.callback {|t| text = t}
+ r.submit_button.callback { answer(text) }.value("Enter")
+ end
end
end
def pause(text)
- @component.display {|r| r.anchor.callback { answer }.with(text) }
+ @component.call_inline {|r| r.anchor.callback { answer }.with(text) }
end
def tell(text)
- @component.display {|r| r.text text.to_s }
+ @component.call_inline {|r| r.text text.to_s }
end
end
View
@@ -1,10 +1,8 @@
$LOAD_PATH.unshift "../lib"
require 'rubygems'
require 'wee'
-require 'wee/conversation'
class CheeseTask < Wee::Task
-
def go
begin choose_cheese end until confirm_cheese
inform_cheese
@@ -24,7 +22,6 @@ def confirm_cheese
def inform_cheese
inform "Your favorite is #{@cheese}."
end
-
end
Wee.runcc(CheeseTask) if __FILE__ == $0
View
@@ -2,13 +2,12 @@ class Counter < Wee::Component
attr_accessor :count
def initialize(initial_count=0)
- super()
- @count = initial_count
+ @count = initial_count
+ add_decoration Wee::StyleDecoration.new(self)
end
- def state(s)
- super
- s.add_ivar(self, :@count, @count)
+ def state(s) super
+ s.add_ivar(self, :@count)
end
def dec
@@ -19,11 +18,12 @@ def inc
@count += 1
end
+ def style
+ ".wee-Counter a { border: 1px dotted blue; margin: 2px; }"
+ end
+
def render(r)
- r.once(self.class) {
- r.css ".wee-Counter a { border: 1px dotted blue; margin: 2px; }"
- }
- r.div.id("wee-#{object_id.to_s(36)}").css_class('wee-Counter').with {
+ r.div.oid.css_class('wee-Counter').with {
r.anchor.callback_method(:dec).with("--")
r.space
render_count(r)

0 comments on commit 8ca9aba

Please sign in to comment.