Class: HerbCombinedNode

Inherits:
Object
  • Object
show all
Defined in:
lib/nodes/herb_combined_node.rb

Instance Method Summary collapse

Constructor Details

#initialize(node_a, node_b) ⇒ HerbCombinedNode

Returns a new instance of HerbCombinedNode.



3
4
5
# File 'lib/nodes/herb_combined_node.rb', line 3

def initialize( node_a, node_b )
  @combined_nodes = [node_a, node_b]
end

Instance Method Details

#can_be_combined?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/nodes/herb_combined_node.rb', line 11

def can_be_combined?
  true
end

#html?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/nodes/herb_combined_node.rb', line 19

def html?
  true
end

#node_nameObject



7
8
9
# File 'lib/nodes/herb_combined_node.rb', line 7

def node_name
  "herb_combined_nodes"
end

#should_be_unrolled?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/nodes/herb_combined_node.rb', line 15

def should_be_unrolled?
  @combined_nodes.last.white_space?
end

#text?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/nodes/herb_combined_node.rb', line 23

def text?
  @combined_nodes.first.text? || @combined_nodes.last.text?
end

#text_valueObject



27
28
29
30
31
32
33
# File 'lib/nodes/herb_combined_node.rb', line 27

def text_value
  to_return = "";
  @combined_nodes.each do |node|
    to_return << node.text_value
  end
  to_return
end

#to_sObject



35
36
37
# File 'lib/nodes/herb_combined_node.rb', line 35

def to_s
  self.text_value
end

#unrollObject



43
44
45
# File 'lib/nodes/herb_combined_node.rb', line 43

def unroll
  @combined_nodes
end

#whitespace?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/nodes/herb_combined_node.rb', line 39

def whitespace?
  @combined_nodes.first.whitespace? || @combined_nodes.last.whitespace?    
end