Class: Nokogiri::XML::Schematron::Nodes::Base Abstract

Inherits:
Base
  • Object
show all
Defined in:
lib/nokogiri/xml/schematron/nodes/base.rb

Overview

This class is abstract.

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.

Instance Attribute Summary collapse

Attributes inherited from Base

#children, #options, #parent

Instance Method Summary collapse

Methods inherited from Base

attribute, element, #to_builder

Constructor Details

#initialize(parent, context, **options) {|node| ... } ⇒ Base

Create a new Nodes::Base object.

Parameters:

Yield Parameters:

Yield Returns:

  • (void)

Raises:

  • (ArgumentError)

    if the XPath is nil.



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, **options, &block)
  @child_node_by_context = {}

  if context.nil?
    raise ::ArgumentError
  else
    @context = context
  end

  super(parent, **options, &block)
end

Instance Attribute Details

#child_node_by_contextHash<String, Nokogiri::XML::Schematron::Nodes::Base> (readonly)

Returns the hash of child nodes by XPaths.

Returns:



13
14
15
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 13

def child_node_by_context
  @child_node_by_context
end

#contextString

Returns the XPath.

Returns:

  • (String)

    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.

Parameters:

  • context (String)

    the XPath.

  • options (Hash<Symbol, Object>)

    the options.

Yield Parameters:

Yield Returns:

  • (void)

Returns:

Raises:

  • (ArgumentError)

    if the XPath is nil.



46
47
48
49
50
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 46

def permit(context, **options, &block)
  node = Nokogiri::XML::Schematron::Nodes::Permit.new(self, context, **options, &block)
  @child_node_by_context[context] = node
  node
end

#reject(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Reject

Create a new Nodes::Reject object.

Parameters:

  • context (String)

    the XPath.

  • options (Hash<Symbol, Object>)

    the options.

Yield Parameters:

Yield Returns:

  • (void)

Returns:

Raises:

  • (ArgumentError)

    if the XPath is nil.



60
61
62
63
64
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 60

def reject(context, **options, &block)
  node = Nokogiri::XML::Schematron::Nodes::Reject.new(self, context, **options, &block)
  @child_node_by_context[context] = node
  node
end

#require(context, **options) {|node| ... } ⇒ Nokogiri::XML::Schematron::Nodes::Require

Create a new Nodes::Require object.

Parameters:

  • context (String)

    the XPath.

  • options (Hash<Symbol, Object>)

    the options.

Yield Parameters:

Yield Returns:

  • (void)

Returns:

Raises:

  • (ArgumentError)

    if the XPath is nil.



74
75
76
77
78
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 74

def require(context, **options, &block)
  node = Nokogiri::XML::Schematron::Nodes::Require.new(self, context, **options, &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.

Parameters:

  • context (String)

    the XPath.

  • options (Hash<Symbol, Object>)

    the options.

Options Hash (**options):

  • :in (Array<String>) — default: []

    the array of available items.

Yield Parameters:

Yield Returns:

  • (void)

Returns:



88
89
90
91
92
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 88

def validates_exclusion_of(context, **options, &block)
  node = Nokogiri::XML::Schematron::Nodes::Validations::Exclusion.new(self, context, **options, &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.

Parameters:

  • context (String)

    the XPath.

  • options (Hash<Symbol, Object>)

    the options.

Options Hash (**options):

  • :in (Array<String>) — default: []

    the array of available items.

Yield Parameters:

Yield Returns:

  • (void)

Returns:



102
103
104
105
106
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 102

def validates_inclusion_of(context, **options, &block)
  node = Nokogiri::XML::Schematron::Nodes::Validations::Inclusion.new(self, context, **options, &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.

Parameters:

  • context (String)

    the XPath.

  • options (Hash<Symbol, Object>)

    the options.

Options Hash (**options):

  • :even (Boolean) — default: false

    Specifies the value must be an even number.

  • :equal_to (Integer, Float) — default: nil

    Specifies the value must be equal to the supplied value.

  • :greater_than (Integer, Float) — default: nil

    Specifies the value must be greater than the supplied value.

  • :greater_than_or_equal_to (Integer, Float) — default: nil

    Specifies the value must be greater than or equal the supplied value.

  • :less_than (Integer, Float) — default: nil

    Specifies the value must be less than the supplied value.

  • :less_than_or_equal_to (Integer, Float) — default: nil

    Specifies the value must be less than or equal the supplied value.

  • :odd (Boolean) — default: false

    Specifies the value must be an odd number.

  • :other_than (Integer, Float) — default: nil

    Specifies the value must be other than the supplied value.

Yield Parameters:

Yield Returns:

  • (void)

Returns:



123
124
125
126
127
# File 'lib/nokogiri/xml/schematron/nodes/base.rb', line 123

def validates_numericality_of(context, **options, &block)
  node = Nokogiri::XML::Schematron::Nodes::Validations::Numericality.new(self, context, **options, &block)
  @child_node_by_context[context] = node
  node
end