Sha256: a279a37606351dae2b8266c9397f7ae4d3e60cbd148656439f65d6d09911a8ff

Contents?: true

Size: 858 Bytes

Versions: 1

Compression:

Stored size: 858 Bytes

Contents

module Quarry

  class Markup #:nodoc:

    # = Macro
    #
    class Macro #< Step

      #def self.inherited(subclass)
      #  types << subclass
      #end

      #def self.types
      #  @types ||= []
      #end

      attr :spec
      attr :code
      attr :lineno

      def initialize(spec, code, lineno, ioc={})
        @spec   = spec
        @code   = code.rstrip
        @lineno = lineno
      end

      alias_method :parent, :spec

      # Run macro.
      def run(runner, spec, context, output)
        context.instance_eval(code, spec.file, lineno)
        output.report_macro(self)
      end

      #
      def tab
        @tab ||= to_s.index(/\S/)
      end

      #
      def to_s ; code ; end

      # As could appear in stand-alone script.
      def to_script
        code.to_s
      end

    end

  end #class Markup

end #module Quarry

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quarry-0.5.2 lib/quarry/markup/macro.rb