Sha256: 81f7e25ba84385ef1d11ac91f598dd0d46b1e033b7edac4f9038f3bf79fed826

Contents?: true

Size: 888 Bytes

Versions: 1

Compression:

Stored size: 888 Bytes

Contents

#
# Implementation of the Arc Challenge using Wee.
#
# By Michael Neumann (mneumann@ntecs.de)
#
# http://onestepback.org/index.cgi/Tech/Ruby/ArcChallenge.red
#

$LOAD_PATH.unshift "../lib"
require 'rubygems'
require 'wee'

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

  def ask
    @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.call_inline {|r| r.anchor.callback { answer }.with(text) }
  end

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

class ArcChallenge < Wee::Task
  def go
    io = Wee::IO.new(self)
    text = io.ask
    io.pause("click here")
    io.tell("You said: #{text}")
  end
end

Wee.run(ArcChallenge) if __FILE__ == $0

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mullen-wee-2.2.0 examples/arc_challenge2.rb