Class: Fmt::Pipeline

Inherits:
Model
  • Object
show all
Defined in:
lib/fmt/models/pipeline.rb

Overview

Note:

Pipelines are processed in sequence (left to right)

Represents a series of Macros

A Pipeline is comprised of:

  1. macros: Array

Instance Attribute Summary collapse

Attributes inherited from Model

#ast, #source, #urtext

AST Processors collapse

Instance Method Summary collapse

Methods inherited from Model

#inspect, #self?

Methods included from Matchable

#deconstruct, #deconstruct_keys

Constructor Details

#initialize(ast) ⇒ Pipeline

Constructor



16
17
18
19
# File 'lib/fmt/models/pipeline.rb', line 16

def initialize(ast)
  @macros = []
  super
end

Instance Attribute Details

#macrosObject (readonly)

: Array



21
22
23
# File 'lib/fmt/models/pipeline.rb', line 21

def macros
  @macros
end

Instance Method Details

#on_macro(node) ⇒ Object

Processes a macro AST node



43
44
45
# File 'lib/fmt/models/pipeline.rb', line 43

def on_macro(node)
  @macros << Macro.new(node)
end

#on_pipeline(node) ⇒ Object

Processes a pipeline AST node



36
37
38
# File 'lib/fmt/models/pipeline.rb', line 36

def on_pipeline(node)
  process_all node.children
end

#to_hObject

Hash representation of the model (required for pattern matching)



25
26
27
# File 'lib/fmt/models/pipeline.rb', line 25

def to_h
  super.merge macros: macros.map(&:to_h)
end