class WWWJDic::Parsers::Key

This class is an implementation of the Parsable duck type that checks the display type. The only needed parameter is the word to translate.

k is the key type:

get an “exact match” and R to get both;

* for Japanese keys use J (this is mandatory for romaji keys),

P to get just “common words” (doesn't work with romaji), K for keys starting with kanji (first position), and L for kanji keys in any position.

(B, U, V, N, etc.) or J if a reading or kanji is being provided. An optional stroke-count or stroke-count range can be included by placing it between “=” characters;

translations“ option.

to include JIS X 0212 kanji, and X for anything else. An optional stroke-count or stroke-count range can be included by placing it between “=” characters.

ISO-2022-JP or UCS, S for Shift_JIS and U for UTF-8, followed by “lookupword=n=kana=”. The kana is optional and is there to disambiguate between different headwords. For “n”, 1 => random selection of 10, anything else => display up to 100 sentences starting at n.

for EUC, ISO-2022-JP or UCS, S for Shift_JIS and U for UTF-8, followed by the search string. Up to 99 example sentences may be displayed.

Author

Marco Bresciani

Copyright

© 2014-2021 Marco Bresciani

License

GNU General Public License version 3

Public Instance Methods

parse(value = :english) click to toggle source

The parsable duck type interface to every parser usage.

   # File lib/wwwjdic/parsers/key.rb
71 def parse(value = :english)
72   raise ArgumentError, I18n.t('error.nil') if value.nil?
73   raise ArgumentError, I18n.t('error.param', value: value) unless value.is_a? Symbol
74
75   raiser_array('error.param', value, KEYS.keys)
76
77   value
78 end