class WWWJDic::Parser
This class is a simple utility that is used to parse
and filter parameters for wwwjdic.
- Author
- Copyright
-
© 2014-2021 Marco Bresciani
- License
-
GNU General Public License version 3
Attributes
parsers[R]
Public Class Methods
new(args = {})
click to toggle source
# File lib/wwwjdic/parser.rb 39 def initialize(args = {}) 40 @parsers = {} 41 ALL_PARAMS.each { |param| parsers[param] = args[param] } unless args.nil? 42 end
Public Instance Methods
parse(method = nil, params = nil)
click to toggle source
Provides the duck type for a generic parsing object.
# File lib/wwwjdic/parser.rb 45 def parse(method = nil, params = nil) 46 a_parser = nil 47 a_parser = parsers[method.to_sym] unless method.nil? || parsers.nil? 48 a_parser&.parse params 49 end