Sha256: ca85524c096d9674d7d9d93b78d694815c113d7ca2ea4c5d6a6a5ee9f090fbab

Contents?: true

Size: 478 Bytes

Versions: 1

Compression:

Stored size: 478 Bytes

Contents

module Scarpe
  class Button
    def initialize(app, text, &block)
      @app = app
      @text = text
      @block = block
      @app.append(render)
    end

    def function_name
      object_id
    end

    def click(&block)
      @block = block
    end

    def render
      @app.bind(function_name) do
        if @block
          @block.call
        end
      end
      "<button id=#{object_id} onclick='scarpeHandler(#{function_name})'>#{@text}</button>"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scarpe-0.1.0 lib/scarpe/button.rb