Class: Liquidice::Transformer::Nodes::TextContent

Inherits:
Base
  • Object
show all
Defined in:
lib/liquidice/transformer/nodes/text_content.rb

Instance Attribute Summary

Attributes inherited from Base

#children, #options, #original_text

Instance Method Summary collapse

Methods inherited from Base

#dot_id, #initialize, #strict_mode?, #transform!, #write_dot, #write_dot_file

Constructor Details

This class inherits a constructor from Liquidice::Transformer::Nodes::Base

Instance Method Details

#can_be_merged?(other) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/liquidice/transformer/nodes/text_content.rb', line 17

def can_be_merged?(other)
  other.is_a?(::Liquidice::Transformer::Nodes::TextContent)
end

#merge(other) ⇒ Object



9
10
11
# File 'lib/liquidice/transformer/nodes/text_content.rb', line 9

def merge(other)
  @original_text += other.original_text
end

#text_valueObject



13
14
15
# File 'lib/liquidice/transformer/nodes/text_content.rb', line 13

def text_value
  @original_text
end

#to_sObject



21
22
23
# File 'lib/liquidice/transformer/nodes/text_content.rb', line 21

def to_s
  @original_text
end

#validate!Object



5
6
7
# File 'lib/liquidice/transformer/nodes/text_content.rb', line 5

def validate!
  raise(Liquidice::Errors::TransformerValidationError, "Children must be empty, it always must be a leaf node") unless children.empty?
end