Class: Reddy::Literal::Encoding
- Inherits:
-
Object
- Object
- Reddy::Literal::Encoding
- Defined in:
- lib/reddy/literal.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Null
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
- .coerce(string_or_nil) ⇒ Object
- .float ⇒ Object
- .integer ⇒ Object
- .string ⇒ Object
- .the_null_encoding ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #format_as_n3(content) ⇒ Object
- #format_as_trix(value) ⇒ Object
- #hash ⇒ Object
-
#initialize(value) ⇒ Encoding
constructor
A new instance of Encoding.
- #inspect ⇒ Object
- #should_quote? ⇒ Boolean
- #to_s ⇒ Object
- #xmlliteral? ⇒ Boolean
Constructor Details
#initialize(value) ⇒ Encoding
Returns a new instance of Encoding.
55 56 57 |
# File 'lib/reddy/literal.rb', line 55 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
54 55 56 |
# File 'lib/reddy/literal.rb', line 54 def value @value end |
Class Method Details
.coerce(string_or_nil) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/reddy/literal.rb', line 16 def self.coerce(string_or_nil) if string_or_nil.nil? || string_or_nil == '' the_null_encoding else new string_or_nil end end |
.float ⇒ Object
8 9 10 |
# File 'lib/reddy/literal.rb', line 8 def self.float @float ||= coerce "http://www.w3.org/2001/XMLSchema#float" end |
.integer ⇒ Object
4 5 6 |
# File 'lib/reddy/literal.rb', line 4 def self.integer @integer ||= coerce "http://www.w3.org/2001/XMLSchema#int" end |
.string ⇒ Object
12 13 14 |
# File 'lib/reddy/literal.rb', line 12 def self.string @string ||= coerce "http://www.w3.org/2001/XMLSchema#string" end |
Instance Method Details
#==(other) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/reddy/literal.rb', line 63 def ==(other) case other when String other == @value when self.class other.value == @value else false end end |
#format_as_n3(content) ⇒ Object
82 83 84 85 |
# File 'lib/reddy/literal.rb', line 82 def format_as_n3(content) quoted_content = should_quote? ? "\"#{content}\"" : content "#{quoted_content}^^<#{value}>" end |
#format_as_trix(value) ⇒ Object
87 88 89 |
# File 'lib/reddy/literal.rb', line 87 def format_as_trix(value) "<typedLiteral datatype=\"#{@value}\">#{value}</typedLiteral>" end |
#hash ⇒ Object
74 75 76 |
# File 'lib/reddy/literal.rb', line 74 def hash @value.hash end |
#inspect ⇒ Object
24 25 26 |
# File 'lib/reddy/literal.rb', line 24 def inspect to_s() end |
#should_quote? ⇒ Boolean
59 60 61 |
# File 'lib/reddy/literal.rb', line 59 def should_quote? @value != self.class.integer.to_s end |
#to_s ⇒ Object
78 79 80 |
# File 'lib/reddy/literal.rb', line 78 def to_s @value end |
#xmlliteral? ⇒ Boolean
91 92 93 |
# File 'lib/reddy/literal.rb', line 91 def xmlliteral? @value == "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral" end |