Class: Liquidice::Transformer::Nodes::HtmlTag

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

Constant Summary collapse

TAG_TYPES =
[
  OPENING_TYPE = :opening,
  CLOSING_TYPE = :closing,
  EMPTY_TYPE = :empty
].freeze

Instance Attribute Summary

Attributes inherited from Base

#children, #options, #original_text

Instance Method Summary collapse

Methods inherited from Base

#can_be_merged?, #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

#closing?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/liquidice/transformer/nodes/html_tag.rb', line 15

def closing?
  type == CLOSING_TYPE
end

#empty?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/liquidice/transformer/nodes/html_tag.rb', line 19

def empty?
  type == EMPTY_TYPE
end

#opening?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/liquidice/transformer/nodes/html_tag.rb', line 11

def opening?
  type == OPENING_TYPE
end

#text_valueObject



32
33
34
# File 'lib/liquidice/transformer/nodes/html_tag.rb', line 32

def text_value
  @original_text
end

#to_sObject



36
37
38
# File 'lib/liquidice/transformer/nodes/html_tag.rb', line 36

def to_s
  @original_text
end

#typeObject



23
24
25
# File 'lib/liquidice/transformer/nodes/html_tag.rb', line 23

def type
  @type ||= options[:type]
end

#validate!Object



27
28
29
30
# File 'lib/liquidice/transformer/nodes/html_tag.rb', line 27

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