Module: Finitio::Syntax::Heading

Includes:
Node
Defined in:
lib/finitio/syntax/type/heading.rb

Instance Method Summary collapse

Methods included from Node

included, #metadata, #resolve_ruby_const, #unique_names!

Instance Method Details

#allow_extra?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/finitio/syntax/type/heading.rb', line 8

def allow_extra?
  !allow_extra.nil?
end

#attributes(factory) ⇒ Object



16
17
18
# File 'lib/finitio/syntax/type/heading.rb', line 16

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

#compile(factory) ⇒ Object



20
21
22
# File 'lib/finitio/syntax/type/heading.rb', line 20

def compile(factory)
  Finitio::Heading.new(attributes(factory), allow_extra: allow_extra?)
end

#multi?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/finitio/syntax/type/heading.rb', line 12

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

#to_astObject



24
25
26
# File 'lib/finitio/syntax/type/heading.rb', line 24

def to_ast
  captures[:attribute].map(&:to_ast).unshift(:heading)
end