Class: Literal
- Inherits:
-
Object
- Object
- Literal
- Defined in:
- lib/rena/literal.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#lang ⇒ Object
Returns the value of attribute lang.
Instance Method Summary collapse
- #==(obj) ⇒ Object
-
#initialize(contents, lang = nil) ⇒ Literal
constructor
A new instance of Literal.
- #to_n3 ⇒ Object
- #to_ntriples ⇒ Object
- #to_trix ⇒ Object
Constructor Details
#initialize(contents, lang = nil) ⇒ Literal
Returns a new instance of Literal.
3 4 5 6 7 8 |
# File 'lib/rena/literal.rb', line 3 def initialize(contents, lang = nil) @contents = contents if lang != nil && lang != false @lang = lang.downcase end end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
2 3 4 |
# File 'lib/rena/literal.rb', line 2 def contents @contents end |
#lang ⇒ Object
Returns the value of attribute lang.
2 3 4 |
# File 'lib/rena/literal.rb', line 2 def lang @lang end |
Instance Method Details
#==(obj) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/rena/literal.rb', line 10 def == (obj) if obj.class == Literal && obj.contents == @contents && (obj.lang == @lang || (obj.lang == nil && @lang == nil)) true else false end end |
#to_n3 ⇒ Object
18 19 20 21 22 23 |
# File 'lib/rena/literal.rb', line 18 def to_n3 out = "\"" + @contents + "\"" out += "@" + @lang if @lang != nil out += "^^" + @encoding if @encoding != nil return out end |
#to_ntriples ⇒ Object
25 26 27 |
# File 'lib/rena/literal.rb', line 25 def to_ntriples return self.to_n3 end |
#to_trix ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rena/literal.rb', line 29 def to_trix if @lang != nil && @lang != false out = "<plainLiteral xml:lang=\"" + @lang + "\">" else out = "<plainLiteral>" end out += @contents out += "</plainLiteral>" return out end |