Module: Nom::XML::NokogiriExtension
- Defined in:
- lib/nom/xml/nokogiri_extension.rb
Instance Method Summary collapse
-
#define_template(name, &block) ⇒ Object
Define a new node template with the Nom::XML::TemplateRegistry.
-
#nom! ⇒ Object
Apply NOM decorators to Nokogiri classes.
-
#set_terminology(options = {}, &block) ⇒ Object
Set the terminology accessors for this document.
- #template_registry ⇒ Object
- #terminology ⇒ Object
- #terminology=(terminology) ⇒ Object
- #terminology_namespaces ⇒ Object
Instance Method Details
#define_template(name, &block) ⇒ Object
Define a new node template with the Nom::XML::TemplateRegistry.
-
name
is a Symbol indicating the name of the new template. -
The
block
does the work of creating the new node, and will receive a Nokogiri::XML::Builder and any other args passed to one of the node instantiation methods.
49 50 51 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 49 def define_template name, &block self.template_registry.define name, &block end |
#nom! ⇒ Object
Apply NOM decorators to Nokogiri classes
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 6 def nom! decorations = { Nokogiri::XML::Node => Nom::XML::Decorators::Terminology, Nokogiri::XML::Attr => Nom::XML::Decorators::Terminology, Nokogiri::XML::NodeSet => Nom::XML::Decorators::NodeSet, Nokogiri::XML::Document => Nom::XML::Decorators::TemplateRegistry } decorations.each_pair do |host, decorator| decorators(host) << decorator unless decorators(host).include? decorator end decorate! self end |
#set_terminology(options = {}, &block) ⇒ Object
Set the terminology accessors for this document
23 24 25 26 27 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 23 def set_terminology = {}, &block @terminology = Nom::XML::Terminology.new(self, , &block) self end |
#template_registry ⇒ Object
41 42 43 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 41 def template_registry @template_registry ||= Nom::XML::TemplateRegistry.new end |
#terminology ⇒ Object
33 34 35 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 33 def terminology @terminology ||= Nom::XML::Terminology.new self end |
#terminology=(terminology) ⇒ Object
37 38 39 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 37 def terminology= terminology @terminology = terminology end |
#terminology_namespaces ⇒ Object
29 30 31 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 29 def terminology_namespaces @terminology.namespaces end |