Module: Gravaty::Utils::Raisers
- Included in:
- Parsers::Format, Parsers::Pixelsize, Parsers::Rating, Parsers::Type, Gravaty::Utils::RpcConnector::RpcConnector
- Defined in:
- lib/gravaty/utils/raisers.rb
Overview
This module contains some utility method to raise errors according to (possibly) common conditions.
- Author
- Copyright
-
Copyright © 2013, 2014, 2015, 2016, 2017, 2018,
2019 Marco Bresciani
- License
-
GNU General Public License version 3
Instance Method Summary collapse
-
#raiser_downcase(name = 'error.value', value = nil, array = nil) ⇒ Object
Raises an
ArgumentError
according to parameters, unless thearray
contains a downcasedvalue
. -
#raiser_to_i(name = 'error.value', value = nil, array = nil) ⇒ Object
Raises an
ArgumentError
according to parameters, unless thearray
contains the number of thevalue
.
Instance Method Details
#raiser_downcase(name = 'error.value', value = nil, array = nil) ⇒ Object
Raises an ArgumentError
according to parameters, unless the array
contains a downcased value
.
46 47 48 49 50 51 |
# File 'lib/gravaty/utils/raisers.rb', line 46 def raiser_downcase(name = 'error.value', value = nil, array = nil) unless value.nil? raise ArgumentError, I18n.t(name, value: value) unless array.include? value.downcase end end |
#raiser_to_i(name = 'error.value', value = nil, array = nil) ⇒ Object
Raises an ArgumentError
according to parameters, unless the array
contains the number of the value
.
55 56 57 58 59 60 |
# File 'lib/gravaty/utils/raisers.rb', line 55 def raiser_to_i(name = 'error.value', value = nil, array = nil) unless value.nil? raise ArgumentError, I18n.t(name, value: value) unless array.include? value.to_i end end |