Class: javajava::util::Locale

Inherits:
Object
  • Object
show all
Defined in:
lib/jactive_support/json/encoders/locale.rb,
lib/jactive_support/java_ext/locale.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.current_localeObject



4
5
6
# File 'lib/jactive_support/java_ext/locale.rb', line 4

def self.current_locale
  self.getDefault
end

.current_locale=(l) ⇒ Object



8
9
10
# File 'lib/jactive_support/java_ext/locale.rb', line 8

def self.current_locale=(l)
  self.setDefault(l.to_locale)
end

Instance Method Details

#human_nameObject



16
17
18
19
20
21
# File 'lib/jactive_support/java_ext/locale.rb', line 16

def human_name
  l = Locale.current_locale
  display_country = country.blank? ? "" : " (#{getDisplayCountry(l)})"
  display_variant = variant.blank? ? "" : " - #{getDisplayVariant(l)}"
  "#{getDisplayLanguage(l)}#{display_country}#{display_variant}"
end

#inspectObject



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

def inspect
  "Locale[#{human_name}]"
end

#to_json(options = {}) ⇒ Object

:nodoc:



3
4
5
# File 'lib/jactive_support/json/encoders/locale.rb', line 3

def to_json(options = {}) #:nodoc:
  ActiveSupport::JSON.encode(to_s)
end

#to_localeObject



12
13
14
# File 'lib/jactive_support/java_ext/locale.rb', line 12

def to_locale
  self
end

#to_strObject



27
28
29
# File 'lib/jactive_support/java_ext/locale.rb', line 27

def to_str
  to_s
end

#to_symObject



31
32
33
# File 'lib/jactive_support/java_ext/locale.rb', line 31

def to_sym
  to_s.to_sym
end