diff options
author | Jochen Topf <jochen@topf.org> | 2010-11-10 16:46:38 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2010-11-10 16:46:38 +0100 |
commit | 5e8df4cebd10e913c563fee0219c724bf46f6761 (patch) | |
tree | 58c48da73ff2ca7e043ab4f29b465052dd45e307 /web/lib | |
parent | 3cbd4b2a577a592a65c96c8eb2cf53346cbfbff3 (diff) | |
download | taginfo-5e8df4cebd10e913c563fee0219c724bf46f6761.tar taginfo-5e8df4cebd10e913c563fee0219c724bf46f6761.tar.gz |
Moved Language class into its own file
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/language.rb | 25 | ||||
-rw-r--r-- | web/lib/utils.rb | 25 |
2 files changed, 25 insertions, 25 deletions
diff --git a/web/lib/language.rb b/web/lib/language.rb new file mode 100644 index 0000000..ec7e819 --- /dev/null +++ b/web/lib/language.rb @@ -0,0 +1,25 @@ +# web/lib/language.rb +class Language + + @@languages = Hash.new + + attr_reader :code, :english_name, :native_name + + def initialize(options) + @code = options['code'] + @english_name = options['english_name'] + @native_name = options['native_name'] + @@languages[@code] = self + end + + def self.[](code) + @@languages[code] || self.new('code' => code, 'english_name' => '(unknown)', 'native_name' => '(unknown)') + end + + def self.each + @@languages.keys.sort.each do |lang| + yield @@languages[lang] + end + end + +end diff --git a/web/lib/utils.rb b/web/lib/utils.rb index b0f488b..f0383ce 100644 --- a/web/lib/utils.rb +++ b/web/lib/utils.rb @@ -1,30 +1,5 @@ # web/lib/utils.rb -class Language - - @@languages = {} - - attr_reader :code, :english_name, :native_name - - def initialize(options) - @code = options['code'] - @english_name = options['english_name'] - @native_name = options['native_name'] - @@languages[@code] = self - end - - def self.[](code) - @@languages[code] || self.new('code' => code, 'english_name' => '(unknown)', 'native_name' => '(unknown)') - end - - def self.each - @@languages.keys.sort.each do |lang| - yield @@languages[lang] - end - end - -end - # patches convenience methods into base classes class Fixnum |