Class: Saxon::ItemType::LexicalStringConversion::FloatConversion
- Inherits:
-
Object
- Object
- Saxon::ItemType::LexicalStringConversion::FloatConversion
- Defined in:
- lib/saxon/item_type/lexical_string_conversion.rb
Overview
Helper class for performing conversion and validation to XDM Floating-point types from Ruby’s Float class
Instance Method Summary collapse
-
#call(value, item_type) ⇒ String
Check a value against our type constraints, and return the lexical string representation if it’s okay.
-
#initialize(size = :double) ⇒ FloatConversion
constructor
A new instance of FloatConversion.
Constructor Details
#initialize(size = :double) ⇒ FloatConversion
Returns a new instance of FloatConversion.
84 85 86 |
# File 'lib/saxon/item_type/lexical_string_conversion.rb', line 84 def initialize(size = :double) @double = size == :double end |
Instance Method Details
#call(value, item_type) ⇒ String
Check a value against our type constraints, and return the lexical string representation if it’s okay.
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/saxon/item_type/lexical_string_conversion.rb', line 94 def call(value, item_type) case value when ::Float::INFINITY 'INF' when -::Float::INFINITY '-INF' when Numeric float_value(value).to_s else LexicalStringConversion.validate(value, item_type, Patterns::FLOAT) end end |