Class: TypedLiteral
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
Attributes inherited from Literal
Instance Method Summary collapse
- #==(obj) ⇒ Object
- #infer! ⇒ Object
-
#initialize(contents, encoding) ⇒ TypedLiteral
constructor
A new instance of TypedLiteral.
- #to_n3 ⇒ Object
- #to_trix ⇒ Object
- #xmlliteral? ⇒ Boolean
Methods inherited from Literal
Constructor Details
#initialize(contents, encoding) ⇒ TypedLiteral
Returns a new instance of TypedLiteral.
44 45 46 47 48 49 50 51 52 |
# File 'lib/rena/literal.rb', line 44 def initialize(contents, encoding) @contents = contents @encoding = encoding if @encoding == "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral" @xmlliteral = true else @xmlliteral = false end end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
43 44 45 |
# File 'lib/rena/literal.rb', line 43 def contents @contents end |
#encoding ⇒ Object
Returns the value of attribute encoding.
43 44 45 |
# File 'lib/rena/literal.rb', line 43 def encoding @encoding end |
Instance Method Details
#==(obj) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/rena/literal.rb', line 54 def == (obj) if obj.class == TypedLiteral && obj.contents == @contents && obj.encoding == @encoding return true else return false end end |
#infer! ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/rena/literal.rb', line 80 def infer! if @contents.class == Fixnum @encoding = "http://www.w3.org/2001/XMLSchema#int" elsif @contents.class == Float @encoding = "http://www.w3.org/2001/XMLSchema#float" else @encoding = "http://www.w3.org/2001/XMLSchema#string" end end |
#to_n3 ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/rena/literal.rb', line 62 def to_n3 if @encoding == "http://www.w3.org/2001/XMLSchema#int" out = @contents.to_s else out = "\"" + @contents.to_s + "\"" end out += "^^<" + @encoding + ">" if @encoding != nil return out end |
#to_trix ⇒ Object
72 73 74 |
# File 'lib/rena/literal.rb', line 72 def to_trix "<typedLiteral datatype=\"" + @encoding + "\">" + @contents + "</typedLiteral>" end |
#xmlliteral? ⇒ Boolean
76 77 78 |
# File 'lib/rena/literal.rb', line 76 def xmlliteral? @xmlliteral end |