Class: Reddy::Literal::Language

Inherits:
Encoding
  • Object
show all
Defined in:
lib/reddy/literal.rb

Instance Attribute Summary

Attributes inherited from Encoding

#value

Instance Method Summary collapse

Methods inherited from Encoding

coerce, float, #hash, #inspect, integer, #should_quote?, string, the_null_encoding, #to_s, #xmlliteral?

Constructor Details

#initialize(string) ⇒ Language

Returns a new instance of Language.



97
98
99
# File 'lib/reddy/literal.rb', line 97

def initialize(string)
  @value = string.downcase
end

Instance Method Details

#==(other) ⇒ Object



116
117
118
119
120
121
122
123
# File 'lib/reddy/literal.rb', line 116

def == (other)
  case other
  when String
    other == @value
  when self.class
    other.value == @value
  end
end

#clean(string) ⇒ Object



101
102
103
104
105
106
# File 'lib/reddy/literal.rb', line 101

def clean(string)
  case string
  when "eng"; "en"
  else string
  end
end

#format_as_n3(contents) ⇒ Object



108
109
110
# File 'lib/reddy/literal.rb', line 108

def format_as_n3(contents)
  "\"#{contents}\"@#{@value}"
end

#format_as_trix(contents) ⇒ Object



112
113
114
# File 'lib/reddy/literal.rb', line 112

def format_as_trix(contents)
  "<plainLiteral xml:lang=\"#{@value}\">#{contents}</plainLiteral>"
end