Class: WWWJDic::Parser
- Inherits:
-
Object
- Object
- WWWJDic::Parser
- Defined in:
- lib/wwwjdic/parser.rb
Overview
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
Instance Attribute Summary collapse
-
#parsers ⇒ Object
readonly
Returns the value of attribute parsers.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Parser
constructor
A new instance of Parser.
-
#parse(method = nil, value = nil) ⇒ Object
Provides the duck type for a generic parsing object.
Constructor Details
#initialize(args = {}) ⇒ Parser
Returns a new instance of Parser.
34 35 36 37 |
# File 'lib/wwwjdic/parser.rb', line 34 def initialize(args = {}) @parsers = Hash.new ALL_PARAMS.each {|param| parsers[param] = args[param]} unless args.nil? end |
Instance Attribute Details
#parsers ⇒ Object (readonly)
Returns the value of attribute parsers.
32 33 34 |
# File 'lib/wwwjdic/parser.rb', line 32 def parsers @parsers end |
Instance Method Details
#parse(method = nil, value = nil) ⇒ Object
Provides the duck type for a generic parsing object.
40 41 42 43 44 |
# File 'lib/wwwjdic/parser.rb', line 40 def parse(method = nil, value = nil) a_parser = nil a_parser = parsers[method.to_sym] unless method.nil? or parsers.nil? a_parser.parse value unless a_parser.nil? end |