Class: Nokogiri::XML::Schematron::Nodes::Base Abstract
- Defined in:
- lib/nokogiri/xml/schematron/nodes/base.rb
Overview
The base class for internal representations of abstract syntax tree (AST) nodes, where the tree is denested and then used to build a sequence of zero or more <sch:rule> elements.
Direct Known Subclasses
Context, Permit, Reject, Require, Validations::Exclusion, Validations::Inclusion, Validations::Numericality
Instance Attribute Summary collapse
-
#child_node_by_context ⇒ Hash<String, Nokogiri::XML::Schematron::Nodes::Base>
readonly
The hash of child nodes by XPaths.
-
#context ⇒ String
The XPath.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(parent, context, **options) {|node| ... } ⇒ Base
constructor
Create a new
Nodes::Base
object. -
#permit(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Permit
Create a new
Nodes::Permit
object. -
#reject(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Reject
Create a new
Nodes::Reject
object. -
#require(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Require
Create a new
Nodes::Require
object. -
#validates_exclusion_of(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Validations::Exclusion
Create a new
Nodes::Validations::Exclusion
object. -
#validates_inclusion_of(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Validations::Inclusion
Create a new
Nodes::Validations::Inclusion
object. -
#validates_numericality_of(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Validations::Numericality
Create a new
Nodes::Validations::Numericality
object.
Methods inherited from Base
attribute, element, #to_builder
Constructor Details
#initialize(parent, context, **options) {|node| ... } ⇒ Base
Create a new Nodes::Base
object.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 26 def initialize(parent, context, **, &block) @child_node_by_context = {} if context.nil? raise ::ArgumentError else @context = context end super(parent, **, &block) end |
Instance Attribute Details
#child_node_by_context ⇒ Hash<String, Nokogiri::XML::Schematron::Nodes::Base> (readonly)
Returns the hash of child nodes by XPaths.
13 14 15 |
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 13 def child_node_by_context @child_node_by_context end |
#context ⇒ String
Returns the XPath.
16 17 18 |
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 16 def context @context end |
Instance Method Details
#permit(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Permit
Create a new Nodes::Permit
object.
46 47 48 49 50 |
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 46 def permit(context, **, &block) node = Nokogiri::XML::Schematron::Nodes::Permit.new(self, context, **, &block) @child_node_by_context[context] = node node end |
#reject(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Reject
Create a new Nodes::Reject
object.
60 61 62 63 64 |
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 60 def reject(context, **, &block) node = Nokogiri::XML::Schematron::Nodes::Reject.new(self, context, **, &block) @child_node_by_context[context] = node node end |
#require(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Require
Create a new Nodes::Require
object.
74 75 76 77 78 |
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 74 def require(context, **, &block) node = Nokogiri::XML::Schematron::Nodes::Require.new(self, context, **, &block) @child_node_by_context[context] = node node end |
#validates_exclusion_of(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Validations::Exclusion
Create a new Nodes::Validations::Exclusion
object.
88 89 90 91 92 |
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 88 def validates_exclusion_of(context, **, &block) node = Nokogiri::XML::Schematron::Nodes::Validations::Exclusion.new(self, context, **, &block) @child_node_by_context[context] = node node end |
#validates_inclusion_of(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Validations::Inclusion
Create a new Nodes::Validations::Inclusion
object.
102 103 104 105 106 |
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 102 def validates_inclusion_of(context, **, &block) node = Nokogiri::XML::Schematron::Nodes::Validations::Inclusion.new(self, context, **, &block) @child_node_by_context[context] = node node end |
#validates_numericality_of(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Validations::Numericality
Create a new Nodes::Validations::Numericality
object.
123 124 125 126 127 |
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 123 def validates_numericality_of(context, **, &block) node = Nokogiri::XML::Schematron::Nodes::Validations::Numericality.new(self, context, **, &block) @child_node_by_context[context] = node node end |