Class: HackTree::Parser::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/hack_tree/parser/base.rb

Overview

Base class for parsers. Parsers generally process text into collection(s).

Direct Known Subclasses

Desc

Instance Method Summary collapse

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