Class: Utopia::Locale

Inherits:
Struct
  • Object
show all
Defined in:
lib/utopia/locale.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#countryObject

Returns the value of attribute country

Returns:

  • (Object)

    the current value of country



22
23
24
# File 'lib/utopia/locale.rb', line 22

def country
  @country
end

#languageObject

Returns the value of attribute language

Returns:

  • (Object)

    the current value of language



22
23
24
# File 'lib/utopia/locale.rb', line 22

def language
  @language
end

#variantObject

Returns the value of attribute variant

Returns:

  • (Object)

    the current value of variant



22
23
24
# File 'lib/utopia/locale.rb', line 22

def variant
  @variant
end

Class Method Details

.dump(instance) ⇒ Object



27
28
29
30
31
# File 'lib/utopia/locale.rb', line 27

def self.dump(instance)
	if instance
		instance.to_s
	end
end

.load(instance) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/utopia/locale.rb', line 33

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_sObject



23
24
25
# File 'lib/utopia/locale.rb', line 23

def to_s
	to_a.compact.join('-')
end