Class: Gravaty::Parsers::Default
- Inherits:
-
Object
- Object
- Gravaty::Parsers::Default
- Defined in:
- lib/gravaty/parsers/default.rb
Overview
This class is an implementation of the Parsable duck type that checks the default option. The only needed parameter is a valid default option.
- Author
rubocop:disable Style/AsciiComments
- Copyright
-
Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
rubocop:enable Style/AsciiComments
- License
-
GNU General Public License version 3
Instance Method Summary collapse
-
#parse(value = nil) ⇒ Object
The parsable duck type interface to every parser usage.
Instance Method Details
#parse(value = nil) ⇒ Object
The parsable duck type interface to every parser usage.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gravaty/parsers/default.rb', line 46 def parse(value = nil) unless value.nil? || value.empty? unless DEFAULT_OPTIONS.include? value valid = %w[http https].index { |scheme| valid?(value, scheme) } raise ArgumentError, I18n.t('error.uri', value: value) if valid.nil? end return "d=#{CGI.escape(value)}" end '' end |