Class: HackTree::Parser::Base
- Inherits:
-
Object
- Object
- HackTree::Parser::Base
- Defined in:
- lib/hack_tree/parser/base.rb
Overview
Base class for parsers. Parsers generally process text into collection(s).
Direct Known Subclasses
Instance Method Summary collapse
-
#[](content) ⇒ Object
Synonym of #process.
-
#initialize(attrs = {}) ⇒ Base
constructor
A new instance of Base.
- #process(content) ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Base
Returns a new instance of Base.
5 6 7 |
# File 'lib/hack_tree/parser/base.rb', line 5 def initialize(attrs = {}) attrs.each {|k, v| send("#{k}=", v)} end |
Instance Method Details
#[](content) ⇒ Object
Synonym of #process.
10 11 12 |
# File 'lib/hack_tree/parser/base.rb', line 10 def [](content) process(content) end |
#process(content) ⇒ Object
14 15 16 17 |
# File 'lib/hack_tree/parser/base.rb', line 14 def process(content) # NOTE: In parser meaning "content" argument name looks more solid. For mapper "data" is more appropriate. Both are okay for their cases. raise "Redefine `process` in your class (#{self.class})" end |