Class: DeepL::Resources::Language

Inherits:
Base
  • Object
show all
Defined in:
lib/deepl/resources/language.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#request, #response

Instance Method Summary collapse

Constructor Details

#initialize(code, name, supports_formality, *args) ⇒ Language

Returns a new instance of Language.



11
12
13
14
15
16
17
# File 'lib/deepl/resources/language.rb', line 11

def initialize(code, name, supports_formality, *args)
  super(*args)

  @code = code
  @name = name
  @supports_formality = supports_formality
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



9
10
11
# File 'lib/deepl/resources/language.rb', line 9

def code
  @code
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/deepl/resources/language.rb', line 9

def name
  @name
end

Instance Method Details

#supports_formality?Boolean

Returns:

  • (Boolean)

Raises:



23
24
25
26
27
# File 'lib/deepl/resources/language.rb', line 23

def supports_formality?
  return @supports_formality unless @supports_formality.nil?

  raise Exceptions::NotSupported, 'Support formality is only available on target languages'
end

#to_sObject



19
20
21
# File 'lib/deepl/resources/language.rb', line 19

def to_s
  "#{code} - #{name}"
end