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.
-
nameis a Symbol indicating the name of the new template. -
The
blockdoes 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.
51 52 53 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 51 def define_template name, &block self.template_registry.define name, &block end |
#nom! ⇒ Object
Apply NOM decorators to Nokogiri classes
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 8 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
25 26 27 28 29 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 25 def set_terminology = {}, &block @terminology = Nom::XML::Terminology.new(self, , &block) self end |
#template_registry ⇒ Object
43 44 45 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 43 def template_registry @template_registry ||= Nom::XML::TemplateRegistry.new end |
#terminology ⇒ Object
35 36 37 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 35 def terminology @terminology ||= Nom::XML::Terminology.new self end |
#terminology=(terminology) ⇒ Object
39 40 41 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 39 def terminology= terminology @terminology = terminology end |
#terminology_namespaces ⇒ Object
31 32 33 |
# File 'lib/nom/xml/nokogiri_extension.rb', line 31 def terminology_namespaces @terminology.namespaces end |