Class: Mangadex::Internal::Definitions::Year

Inherits:
Base
  • Object
show all
Defined in:
lib/mangadex/internal/definitions/year.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) ⇒ Year

Returns a new instance of Year.



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

def initialize(value)
  super(
    value,
    key: :year,
    accepts: Accepts.new(
      array: ["none"],
      class: Integer,
      condition: :or,
    ),
    required: false,
  )
end

Instance Method Details

#validate_acceptsObject



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

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