Class: TranslationOption

Inherits:
Object
  • Object
show all
Defined in:
lib/models/translation_option.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, description) ⇒ TranslationOption

Returns a new instance of TranslationOption.



6
7
8
# File 'lib/models/translation_option.rb', line 6

def initialize(code, description)
  @code, @description = code, description
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



3
4
5
# File 'lib/models/translation_option.rb', line 3

def code
  @code
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/models/translation_option.rb', line 3

def description
  @description
end

Class Method Details

.allObject



10
11
12
# File 'lib/models/translation_option.rb', line 10

def self.all
  [untranslated, translated]
end

.find(code) ⇒ Object



22
23
24
# File 'lib/models/translation_option.rb', line 22

def self.find(code)
  all.detect{|option| option.code == code} || untranslated
end

.translatedObject



14
15
16
# File 'lib/models/translation_option.rb', line 14

def self.translated
  @@translated ||= TranslationOption.new('translated', 'Translated')
end

.untranslatedObject



18
19
20
# File 'lib/models/translation_option.rb', line 18

def self.untranslated
  @@untranslated ||= TranslationOption.new('untranslated', 'Untranslated')
end