Class: LocalizedString

Inherits:
String
  • Object
show all
Includes:
RDFS::Literal
Defined in:
lib/active_rdf/objectmanager/literal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RDFS::Literal

typed, #xsd_type

Constructor Details

#initialize(value, lang) ⇒ LocalizedString

Returns a new instance of LocalizedString.



79
80
81
82
# File 'lib/active_rdf/objectmanager/literal.rb', line 79

def initialize(value, lang)
  super(value)
  @lang = lang.sub(/^@/,'')
end

Instance Attribute Details

#langObject (readonly)

Returns the value of attribute lang.



78
79
80
# File 'lib/active_rdf/objectmanager/literal.rb', line 78

def lang
  @lang
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



84
85
86
87
88
89
90
# File 'lib/active_rdf/objectmanager/literal.rb', line 84

def ==(other)
  if other.is_a?(LocalizedString)
    super && @lang == other.lang
  else
    super
  end
end

#inspectObject



93
94
95
# File 'lib/active_rdf/objectmanager/literal.rb', line 93

def inspect
  super + "@#@lang"
end

#to_literal_sObject

returns quoted string with language type if present. xsd:string isn’t appended when lang missing (xsd:string should be considered the default type)



99
100
101
# File 'lib/active_rdf/objectmanager/literal.rb', line 99

def to_literal_s
  $activerdf_without_datatype ? "\"#{self}\"" : "\"#{self}\"@#@lang"
end