Sha256: d9c74938e7721822eba7118ac62bbdfbe1fa76d4e3910caa1454f634630f97f5
Contents?: true
Size: 655 Bytes
Versions: 1
Compression:
Stored size: 655 Bytes
Contents
class Counter < Wee::Component attr_accessor :count def initialize(initial_count=0) @count = initial_count add_decoration Wee::StyleDecoration.new(self) end def state(s) super s.add_ivar(self, :@count) end def dec @count -= 1 end def inc @count += 1 end def style ".wee-Counter a { border: 1px dotted blue; margin: 2px; }" end def render(r) r.div.oid.css_class('wee-Counter').with { r.anchor.callback_method(:dec).with("--") r.space render_count(r) r.space r.anchor.callback_method(:inc).with("++") } end def render_count(r) r.text @count.to_s end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mullen-wee-2.2.0 | examples/demo/counter.rb |