Module: Saxon::ItemType::ValueToRuby::Convertors

Defined in:
lib/saxon/item_type/value_to_ruby.rb

Overview

A collection of Lambdas (or objects responding to #call) for converting XDM typed values to native Ruby types.

Constant Summary collapse

INTEGER =
INT = SHORT = LONG = UNSIGNED_INT = UNSIGNED_SHORT = UNSIGNED_LONG = \
POSITIVE_INTEGER = NON_POSITIVE_INTEGER = NEGATIVE_INTEGER = NON_NEGATIVE_INTEGER = ->(xdm_atomic_value) {
  xdm_atomic_value.to_java.getValue
}
DECIMAL =
->(xdm_atomic_value) {
  BigDecimal(xdm_atomic_value.to_s)
}
FLOAT =
DOUBLE = ->(xdm_atomic_value) {
  xdm_atomic_value.to_java.getValue
}
DATE_TIME =
DATE_TIME_STAMP = ValueToRuby::DateTimeConvertor
BOOLEAN =
->(xdm_atomic_value) {
  xdm_atomic_value.to_java.getValue
}
NOTATION =
QNAME = ->(xdm_atomic_value) {
  Saxon::QName.new(xdm_atomic_value.to_java.getQNameValue)
}
BASE64_BINARY =
->(xdm_atomic_value) {
  Base64.decode64(xdm_atomic_value.to_s)
}
HEX_BINARY =
->(xdm_atomic_value) {
  bytes = []
  xdm_atomic_value.to_s.scan(/../) { |x| bytes << x.hex.chr(Encoding::ASCII_8BIT) }
  bytes.join
}
BYTE =
->(xdm_atomic_value) {
  [xdm_atomic_value.to_java.getLongValue].pack('c')
}
UNSIGNED_BYTE =
->(xdm_atomic_value) {
  [xdm_atomic_value.to_java.getLongValue].pack('C')
}