Class: Sequence::SequenceTemplate::ConditionalSection
- Inherits:
-
Section
- Object
- UnaryElement
- Section
- Sequence::SequenceTemplate::ConditionalSection
- Defined in:
- lib/lucid/sequence/sequence_template.rb
Instance Attribute Summary collapse
-
#existence ⇒ Object
readonly
Returns the value of attribute existence.
Attributes inherited from Section
Attributes inherited from UnaryElement
Instance Method Summary collapse
-
#initialize(name, generate) ⇒ ConditionalSection
constructor
A new instance of ConditionalSection.
- #output(context, params) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Section
Methods inherited from UnaryElement
Constructor Details
#initialize(name, generate) ⇒ ConditionalSection
Returns a new instance of ConditionalSection.
96 97 98 99 |
# File 'lib/lucid/sequence/sequence_template.rb', line 96 def initialize(name, generate) super(name) @existence = generate end |
Instance Attribute Details
#existence ⇒ Object (readonly)
Returns the value of attribute existence.
94 95 96 |
# File 'lib/lucid/sequence/sequence_template.rb', line 94 def existence @existence end |
Instance Method Details
#output(context, params) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/lucid/sequence/sequence_template.rb', line 101 def output(context, params) value = retrieve_value_from(context, params) if (!value.nil? && existence) || (value.nil? && !existence) result = children.each_with_object('') do |child, item| item << child.output(context, params) end else result = '' end return result end |
#to_s ⇒ Object
114 115 116 |
# File 'lib/lucid/sequence/sequence_template.rb', line 114 def to_s return "<?#{name}>" end |