Class: WWWJDic::Parsers::Display

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

Overview

This class is an implementation of the Parsable duck type that checks the display type. The only needed parameter is a boolean, with true for regular.

M = backdoor entry (regular display) or Z = backdoor entry (raw dictionary display)

Author

Marco Bresciani

Copyright

© 2014-2021 Marco Bresciani

License

GNU General Public License version 3

Instance Method Summary collapse

Methods included from Utils::Raisers

#raiser_array, #raiser_downcase, #raiser_to_i

Instance Method Details

#parse(value = :display) ⇒ Object

The parsable duck type interface to every parser usage.

Raises:

  • (ArgumentError)


45
46
47
48
49
50
51
52
# File 'lib/wwwjdic/parsers/display.rb', line 45

def parse(value = :display)
  raise ArgumentError, I18n.t('error.nil') if value.nil?
  raise ArgumentError, I18n.t('error.param', value: value) unless value.is_a? Symbol

  raiser_array('error.param', value, DISPLAY.keys)

  value
end