Class: Sequence::SequenceTemplate::Section

Inherits:
UnaryElement show all
Defined in:
lib/lucid/sequence/sequence_template.rb

Direct Known Subclasses

ConditionalSection

Instance Attribute Summary collapse

Attributes inherited from UnaryElement

#name

Instance Method Summary collapse

Methods inherited from UnaryElement

#retrieve_value_from

Constructor Details

#initialize(name) ⇒ Section

Returns a new instance of Section.



64
65
66
67
# File 'lib/lucid/sequence/sequence_template.rb', line 64

def initialize(name)
  super(name)
  @children = []
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



62
63
64
# File 'lib/lucid/sequence/sequence_template.rb', line 62

def children
  @children
end

Instance Method Details

#add_child(child) ⇒ Object



69
70
71
# File 'lib/lucid/sequence/sequence_template.rb', line 69

def add_child(child)
  children << child
end

#output(context, params) ⇒ Object

Raises:

  • (NotImplementedError)


87
88
89
90
# File 'lib/lucid/sequence/sequence_template.rb', line 87

def output(context, params)
  msg = "Method Section.#{__method__} must be implemented in subclass."
  raise NotImplementedError, msg
end

#variablesObject



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/lucid/sequence/sequence_template.rb', line 73

def variables
  section_variables = children.each_with_object([]) do |child, result|
    case child
      when Placeholder
        result << child.name
      when Section
        result.concat(child.variables)
      else
        # noop
    end
  end
  return section_variables.flatten.uniq
end