class Mlc::Abstract::Snippet

Public Class Methods

new() click to toggle source
# File lib/mlc/abstract/snippet.rb, line 4
def initialize
  @children = []
end

Public Instance Methods

<<(child) click to toggle source
# File lib/mlc/abstract/snippet.rb, line 24
def <<(child)
  @children << child
end
to_lua(opts = {}) click to toggle source
# File lib/mlc/abstract/snippet.rb, line 8
      def to_lua(opts = {})
        template = <<URMOM
(function (mlc)
  local _scope, _global, _const, _ = mlc.scope, mlc.global, mlc.const, mlc.helpers
LVARS
STUFF

end)(Mlc)
URMOM
        state = Mlc::ParserState.new
        (opts[:require] ? "local Mlc = require('mlc')\n" : '') +
          template.gsub('STUFF', @children.first.to_lua(1, opts, state)).
          gsub('LVARS', state.lvars.empty? ? '' : "\n  #{state.lvars_define}")

      end