Class: LocalizedString
Overview
LocalizedString is just a common String with “lang” attribute, which specifies the language of the text stored in the string.
Instance Attribute Summary collapse
-
#lang ⇒ Object
readonly
Returns the value of attribute lang.
Instance Method Summary collapse
-
#eql?(str) ⇒ Boolean
(also: #==)
In addition to comparing string values LocalizedString also compares “lang” values.
-
#initialize(str, lng = nil) ⇒ LocalizedString
constructor
A new instance of LocalizedString.
Methods inherited from String
Constructor Details
#initialize(str, lng = nil) ⇒ LocalizedString
Returns a new instance of LocalizedString.
10 11 12 13 |
# File 'lib/ext/localized_string.rb', line 10 def initialize(str, lng = nil) @lang = lng super str end |
Instance Attribute Details
#lang ⇒ Object (readonly)
Returns the value of attribute lang.
8 9 10 |
# File 'lib/ext/localized_string.rb', line 8 def lang @lang end |
Instance Method Details
#eql?(str) ⇒ Boolean Also known as: ==
In addition to comparing string values LocalizedString also compares “lang” values. When compared to a common String, “lang” value is ignored.
22 23 24 25 26 27 28 |
# File 'lib/ext/localized_string.rb', line 22 def eql?(str) if str.respond_to?(:lang) self.lang == str.lang && super else super end end |