Class: Mangadex::Internal::Definitions::ContentRating

Inherits:
Base
  • Object
show all
Defined in:
lib/mangadex/internal/definitions/content_rating.rb

Instance Attribute Summary

Attributes inherited from Base

#accepts, #converts, #errors, #key

Instance Method Summary collapse

Methods inherited from Base

#empty?, #error_message, #valid?, #validate, #validate!, #value

Constructor Details

#initialize(value) ⇒ ContentRating

Returns a new instance of ContentRating.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/mangadex/internal/definitions/content_rating.rb', line 7

def initialize(value)
  super(
    value,
    key: :content_rating,
    accepts: Accepts.new(
      array: Mangadex::ContentRating::VALUES,
      class: Mangadex::ContentRating,
      condition: :or,
    ),
    converts: :to_s,
    required: false,
  )
end

Instance Method Details

#validate_acceptsObject



21
22
23
24
25
# File 'lib/mangadex/internal/definitions/content_rating.rb', line 21

def validate_accepts
  @accepts.validate!(converted_value)
rescue ArgumentError => error
  add_error(error.message)
end

#validate_conditionObject



27
28
29
# File 'lib/mangadex/internal/definitions/content_rating.rb', line 27

def validate_condition

end