class Nokogiri::XML::Schematron::Nodes::Validations::Numericality
The abstract syntax tree node that uses the +number(any)+ XPath function, where any
is any value, to test if the +@context+ XML
attribute is numeric.
Constants
- PROC_BY_METHOD_NAME
@return [Hash<Symbol, Proc>] the hash of blocks by method name.
Protected Instance Methods
build_assertion!(xml)
click to toggle source
# File lib/nokogiri/xml/schematron/nodes/validations/numericality.rb, line 47 def build_assertion!(xml) tests = [ "number(#{@context}) = #{@context}", ] messages = [ "MUST be a number", ] PROC_BY_METHOD_NAME.each do |method_name, block| unless (orig_value = send(method_name.to_sym)).nil? || (pair = block.call(orig_value)).nil? tests << pair[0] messages << pair[1] end end xml["sch"].send(:assert, xmlns.merge({ "test" => tests.collect { |s| "(#{s})" }.join(" and "), })) do xml.text("text \"") xml["sch"].send(:"value-of", { "select" => @context, }) xml.text("\": element \"#{@context}\" #{Nokogiri::XML::Schematron::Internal::CoreExt::Array.to_sentence(messages, last_word_connector: ", and ", two_words_connector: " and ", words_connector: ", ")}") end return end