Sha256: 44c3e85e87d8314f606be2417130d13178b3022313a3c892ce8560ab34136211

Contents?: true

Size: 740 Bytes

Versions: 16

Compression:

Stored size: 740 Bytes

Contents

module Finitio
  module Syntax
    module Heading
      include Node

      capture :allow_extra

      def allow_extra?
        !allow_extra.nil?
      end

      def multi?
        captures[:attribute].any?{|a| a.optional? } or allow_extra?
      end

      def attributes(factory)
        captures[:attribute].map{|a| a.compile(factory) }
      end

      def compile(factory)
        options = allow_extra ? allow_extra.compile(factory) : {}
        Finitio::Heading.new(attributes(factory), options)
      end

      def to_ast
        ast = captures[:attribute].map(&:to_ast).unshift(:heading)
        ast << allow_extra.to_ast if allow_extra
        ast
      end

    end # module Heading
  end # module Syntax
end # module Finitio

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
finitio-0.12.0 lib/finitio/syntax/type/heading.rb
finitio-0.11.4 lib/finitio/syntax/type/heading.rb
finitio-0.11.3 lib/finitio/syntax/type/heading.rb
finitio-0.11.2 lib/finitio/syntax/type/heading.rb
finitio-0.11.1 lib/finitio/syntax/type/heading.rb
finitio-0.10.0 lib/finitio/syntax/type/heading.rb
finitio-0.9.1 lib/finitio/syntax/type/heading.rb
finitio-0.9.0 lib/finitio/syntax/type/heading.rb
finitio-0.8.0 lib/finitio/syntax/type/heading.rb
finitio-0.7.0 lib/finitio/syntax/type/heading.rb
finitio-0.7.0.pre.rc4 lib/finitio/syntax/type/heading.rb
finitio-0.7.0.pre.rc3 lib/finitio/syntax/type/heading.rb
finitio-0.7.0.pre.rc2 lib/finitio/syntax/type/heading.rb
finitio-0.7.0.pre.rc1 lib/finitio/syntax/type/heading.rb
finitio-0.6.1 lib/finitio/syntax/type/heading.rb
finitio-0.6.0 lib/finitio/syntax/type/heading.rb