Module: RDFS::Literal
- Included in:
- Date, DateTime, FalseClass, Float, Integer, LocalizedString, String, Time, TrueClass
- Defined in:
- lib/active_rdf/objectmanager/literal.rb
Class Attribute Summary collapse
-
.class_uri ⇒ Object
Returns the value of attribute class_uri.
Class Method Summary collapse
-
.typed(value, type) ⇒ Object
convert value to class type.
Instance Method Summary collapse
- #to_literal_s ⇒ Object
- #xsd_type ⇒ Object (also: #datatype)
Class Attribute Details
.class_uri ⇒ Object
Returns the value of attribute class_uri.
9 10 11 |
# File 'lib/active_rdf/objectmanager/literal.rb', line 9 def class_uri @class_uri end |
Class Method Details
.typed(value, type) ⇒ Object
convert value to class type
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/active_rdf/objectmanager/literal.rb', line 13 def self.typed(value, type) case type when XSD::string String.new(value) when XSD::integer value.to_i when XSD::double value.to_f when XSD::boolean value == 'true' or value == 1 when XSD::dateTime DateTime.parse(value) when XSD::time Time.parse(value) when XSD::date Date.parse(value) else value end end |
Instance Method Details
#to_literal_s ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/active_rdf/objectmanager/literal.rb', line 54 def to_literal_s s = kind_of?(Time) ? xmlschema : to_s unless $activerdf_without_datatype "\"#{s}\"^^<#{xsd_type}>" else "\"#{s}\"" end end |
#xsd_type ⇒ Object Also known as: datatype
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/active_rdf/objectmanager/literal.rb', line 34 def xsd_type case self when String XSD::string when Integer XSD::integer when Float XSD::double when TrueClass, FalseClass XSD::boolean when DateTime XSD::dateTime when Date XSD::date when Time XSD::time end end |