Class: LanguageTool::Resources::Language

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/languagetool/resources/language.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Language

Returns a new instance of Language.



8
9
10
11
12
# File 'lib/languagetool/resources/language.rb', line 8

def initialize(json)
  @name = json['name']
  @code = json['code']
  @long_code = json['longCode'] || json['code']
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/languagetool/resources/language.rb', line 6

def code
  @code
end

#long_codeObject (readonly)

Returns the value of attribute long_code.



6
7
8
# File 'lib/languagetool/resources/language.rb', line 6

def long_code
  @long_code
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/languagetool/resources/language.rb', line 6

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



18
19
20
# File 'lib/languagetool/resources/language.rb', line 18

def <=>(other)
  long_code <=> other.long_code
end

#to_sObject



14
15
16
# File 'lib/languagetool/resources/language.rb', line 14

def to_s
  "#{name} (#{long_code})"
end