Class: Utopia::Locale
- Inherits:
-
Struct
- Object
- Struct
- Utopia::Locale
- Defined in:
- lib/utopia/locale.rb
Overview
A structured representation of locale based on RFC3066.
Instance Attribute Summary collapse
-
#country ⇒ Object
Returns the value of attribute country.
-
#language ⇒ Object
Returns the value of attribute language.
-
#variant ⇒ Object
Returns the value of attribute variant.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#country ⇒ Object
Returns the value of attribute country
25 26 27 |
# File 'lib/utopia/locale.rb', line 25 def country @country end |
#language ⇒ Object
Returns the value of attribute language
25 26 27 |
# File 'lib/utopia/locale.rb', line 25 def language @language end |
#variant ⇒ Object
Returns the value of attribute variant
25 26 27 |
# File 'lib/utopia/locale.rb', line 25 def variant @variant end |
Class Method Details
.dump(instance) ⇒ Object
30 31 32 33 34 |
# File 'lib/utopia/locale.rb', line 30 def self.dump(instance) if instance instance.to_s end end |
.load(instance) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/utopia/locale.rb', line 36 def self.load(instance) if instance.is_a? String self.new(*instance.split('-', 3)) elsif instance.is_a? Array return self.new(*instance) elsif instance.is_a? self return instance.frozen? ? instance : instance.dup end end |
Instance Method Details
#to_s ⇒ Object
26 27 28 |
# File 'lib/utopia/locale.rb', line 26 def to_s to_a.compact.join('-') end |