Class: DeepL::Resources::LanguageResource

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

Overview

A DeepL API resource and the features it supports, as returned by DeepL::Client#get_language_resources.

Instance Attribute Summary collapse

Attributes inherited from Base

#request, #response

Instance Method Summary collapse

Constructor Details

#initialize(resource, *args) ⇒ LanguageResource

Returns a new instance of LanguageResource.



37
38
39
40
41
42
43
44
45
# File 'lib/deepl/resources/language_resource.rb', line 37

def initialize(resource, *args)
  super(*args)

  @name = resource['name']
  @features = (resource['features'] || []).to_h do |feature|
    resource_feature = ResourceFeature.new(feature)
    [resource_feature.name, resource_feature]
  end
end

Instance Attribute Details

#features ⇒ Object (readonly)

Returns the value of attribute features.



35
36
37
# File 'lib/deepl/resources/language_resource.rb', line 35

def features
  @features
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



35
36
37
# File 'lib/deepl/resources/language_resource.rb', line 35

def name
  @name
end

Instance Method Details

#supports?(feature) ⇒ Boolean

Returns true if this resource exposes the given feature (e.g. 'glossary').

Returns:

  • (Boolean)


52
53
54
# File 'lib/deepl/resources/language_resource.rb', line 52

def supports?(feature)
  features.key?(feature.to_s)
end

#to_s ⇒ Object



47
48
49
# File 'lib/deepl/resources/language_resource.rb', line 47

def to_s
  name
end