Sha256: c178ec7611000e7202bf088b09a47c8fb91512d8286c8e18f5ecd18b06d92df9
Contents?: true
Size: 1.23 KB
Versions: 4
Compression:
Stored size: 1.23 KB
Contents
# Copyright: Copyright 2010 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 module RTM::Sugar::Occurrence module DynamicValue # Given the occurrence's datatype this method returns the value of this # occurrence cast as appropriate Ruby type. # # :call-seq: # dynamic_value -> Object # def dynamic_value value = self.value # a String case self.datatype.reference when RTM::PSI[:IRI] return topic_map.create_locator(value) when RTM::PSI[:Decimal] return value.to_f when RTM::PSI[:Double] return value.to_f when RTM::PSI[:Int] return value.to_i when RTM::PSI[:Integer] return value.to_i when RTM::PSI[:Float] return value.to_f when RTM::PSI[:Long] return value.to_i when RTM::PSI[:Date] return Date.parse(value) when RTM::PSI[:DateTime] return DateTime.parse(value) when RTM::PSI[:Time] return Time.parse(value) else return value end end end end class Float def to_xsd_double s = self.to_s case s when "Infinity" "INF" when "-Infinity" "-INF" else s end end end
Version data entries
4 entries across 4 versions & 1 rubygems