class WWWJDic::Parser
This class is a simple utility that is used to parse
and filter parameters for wwwjdic.
- Author
- Copyright
-
Copyright © 2014, 2015, 2016, 2017, 2018, 2019 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 34 def initialize(args = {}) 35 @parsers = Hash.new 36 ALL_PARAMS.each {|param| parsers[param] = args[param]} unless args.nil? 37 end
Public Instance Methods
parse(method = nil, value = nil)
click to toggle source
Provides the duck type for a generic parsing object.
# File lib/wwwjdic/parser.rb 40 def parse(method = nil, value = nil) 41 a_parser = nil 42 a_parser = parsers[method.to_sym] unless method.nil? or parsers.nil? 43 a_parser.parse value unless a_parser.nil? 44 end