Sha256: 795ae644ea83c7ec178c196d4f8d6b96dec76324fc21a062e29076cff0546e0f

Contents?: true

Size: 624 Bytes

Versions: 2

Compression:

Stored size: 624 Bytes

Contents

module Weaver
  class Action
    def initialize(page, anchors, &block)
      @page = page
      @anchors = anchors

      actionsArray = @anchors['action']

      @anchors['action'] = [] unless @anchors['action']

      actionsArray = @anchors['action']

      @actionName = "action#{actionsArray.length}"
      actionsArray << @actionName

      @code = ''

      instance_eval(&block)
    end

    def script(code)
      @code = code
    end

    def generate
      # puts @code
      <<-FUNCTION
function #{@actionName}(caller, data) {
	#{@code}
}
      FUNCTION
    end

    def name
      @actionName
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
weaver-0.8.2 lib/weaver/element_types/action.rb
weaver-0.8.1 lib/weaver/element_types/action.rb