Module: Renshi::Node

Defined in:
lib/renshi/node.rb

Overview

helper methods for Renshi on the Nokogiri XMLNode

Instance Method Summary collapse

Instance Method Details

#close_clause(closing) ⇒ Object

typically an end statement



19
20
21
# File 'lib/renshi/node.rb', line 19

def close_clause(closing)
  self.after("#{Renshi::Parser::STRING_END} #{closing}; #{Renshi::Parser::STRING_START}")
end

#commandsObject



5
6
7
8
9
10
11
# File 'lib/renshi/node.rb', line 5

def commands
  commands = []
  for key in self.keys
    commands << [key, self.attributes[key]] if key[0..1] == "r:"
  end
  return commands
end

#next_realObject

just a hack on next, as Nokogiri returns a new line as the next sibling.



24
25
26
27
28
29
30
31
32
# File 'lib/renshi/node.rb', line 24

def next_real
  sibling = self.next
  
  while sibling and sibling.text.strip == ""
    sibling = sibling.next
  end
  
  return sibling
end

#open_clause(opening) ⇒ Object

opens a clause on an element, for example an if statement on a div



14
15
16
# File 'lib/renshi/node.rb', line 14

def open_clause(opening)
  self.before("#{Renshi::Parser::STRING_END} #{opening}; #{Renshi::Parser::STRING_START}")    
end