Skip to content
This repository has been archived by the owner on Dec 25, 2020. It is now read-only.

Commit

Permalink
Bring examples up-to-date with latest commits
Browse files Browse the repository at this point in the history
  • Loading branch information
mneumann committed Jan 6, 2010
1 parent 2cb116e commit 8ca9aba
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
15 changes: 8 additions & 7 deletions examples/arc_challenge2.rb
Expand Up @@ -9,27 +9,28 @@
$LOAD_PATH.unshift "../lib" $LOAD_PATH.unshift "../lib"
require 'rubygems' require 'rubygems'
require 'wee' require 'wee'
require "wee/conversation"


class Wee::IO class Wee::IO
def initialize(component) def initialize(component)
@component = component @component = component
end end


def ask def ask
@component.display do |r| @component.call_inline do |r|
text = nil r.form do
r.text_input.callback {|t| text = t} text = nil
r.submit_button.callback { answer(text) }.value("Enter") r.text_input.callback {|t| text = t}
r.submit_button.callback { answer(text) }.value("Enter")
end
end end
end end


def pause(text) def pause(text)
@component.display {|r| r.anchor.callback { answer }.with(text) } @component.call_inline {|r| r.anchor.callback { answer }.with(text) }
end end


def tell(text) def tell(text)
@component.display {|r| r.text text.to_s } @component.call_inline {|r| r.text text.to_s }
end end
end end


Expand Down
3 changes: 0 additions & 3 deletions examples/cheese_task.rb
@@ -1,10 +1,8 @@
$LOAD_PATH.unshift "../lib" $LOAD_PATH.unshift "../lib"
require 'rubygems' require 'rubygems'
require 'wee' require 'wee'
require 'wee/conversation'


class CheeseTask < Wee::Task class CheeseTask < Wee::Task

def go def go
begin choose_cheese end until confirm_cheese begin choose_cheese end until confirm_cheese
inform_cheese inform_cheese
Expand All @@ -24,7 +22,6 @@ def confirm_cheese
def inform_cheese def inform_cheese
inform "Your favorite is #{@cheese}." inform "Your favorite is #{@cheese}."
end end

end end


Wee.runcc(CheeseTask) if __FILE__ == $0 Wee.runcc(CheeseTask) if __FILE__ == $0
18 changes: 9 additions & 9 deletions examples/demo/counter.rb
Expand Up @@ -2,13 +2,12 @@ class Counter < Wee::Component
attr_accessor :count attr_accessor :count


def initialize(initial_count=0) def initialize(initial_count=0)
super() @count = initial_count
@count = initial_count add_decoration Wee::StyleDecoration.new(self)
end end


def state(s) def state(s) super
super s.add_ivar(self, :@count)
s.add_ivar(self, :@count, @count)
end end


def dec def dec
Expand All @@ -19,11 +18,12 @@ def inc
@count += 1 @count += 1
end end


def style
".wee-Counter a { border: 1px dotted blue; margin: 2px; }"
end

def render(r) def render(r)
r.once(self.class) { r.div.oid.css_class('wee-Counter').with {
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.anchor.callback_method(:dec).with("--") r.anchor.callback_method(:dec).with("--")
r.space r.space
render_count(r) render_count(r)
Expand Down

0 comments on commit 8ca9aba

Please sign in to comment.