Class: Gravaty::Parsers::Rating

Inherits:
Object
  • Object
show all
Includes:
Utils::Raisers
Defined in:
lib/gravaty/parsers/rating.rb

Overview

This class is an implementation of the Parsable duck type that checks the rating type. The only needed parameter is a valid rating type.

Author

Marco Bresciani

Copyright

Copyright © 2013, 2014, 2015, 2016, 2017, 2018,

2019 Marco Bresciani

License

GNU General Public License version 3

Instance Method Summary collapse

Methods included from Utils::Raisers

#raiser_downcase, #raiser_to_i

Instance Method Details

#parse(value = nil) ⇒ Object

the parsable duck type interface to every parser usage.



39
40
41
42
# File 'lib/gravaty/parsers/rating.rb', line 39

def parse(value = nil)
  raiser_downcase('error.value', value, RATING_OPTIONS)
  value.nil? ? '' : "rating=#{value.downcase.to_s}"
end