Class: FakePipe::TextBlock
- Inherits:
-
Object
- Object
- FakePipe::TextBlock
- Defined in:
- lib/fake_pipe/text_block.rb
Overview
Blocks are considered between the #start_text? and #end_text? Any lines in between the start and end are passed to #parse
find interesting.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#delegate ⇒ Object
Returns the value of attribute delegate.
-
#start_match ⇒ Object
Returns the value of attribute start_match.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
- #end_text?(line) ⇒ Boolean
-
#initialize(delegate:) ⇒ TextBlock
constructor
A new instance of TextBlock.
- #match_start_text(line) ⇒ Object
-
#on_start_text(_match, _line) ⇒ Object
Override to do something interesting with the initial match or line.
- #parse(_line) ⇒ Object
- #start_text? ⇒ Boolean
Constructor Details
#initialize(delegate:) ⇒ TextBlock
Returns a new instance of TextBlock.
14 15 16 |
# File 'lib/fake_pipe/text_block.rb', line 14 def initialize(delegate:) self.delegate = delegate end |
Instance Attribute Details
#delegate ⇒ Object
Returns the value of attribute delegate.
12 13 14 |
# File 'lib/fake_pipe/text_block.rb', line 12 def delegate @delegate end |
#start_match ⇒ Object
Returns the value of attribute start_match.
12 13 14 |
# File 'lib/fake_pipe/text_block.rb', line 12 def start_match @start_match end |
#table ⇒ Object
Returns the value of attribute table.
12 13 14 |
# File 'lib/fake_pipe/text_block.rb', line 12 def table @table end |
Instance Method Details
#end_text?(line) ⇒ Boolean
26 27 28 |
# File 'lib/fake_pipe/text_block.rb', line 26 def end_text?(line) end_pattern && !!end_pattern.match(line) end |
#match_start_text(line) ⇒ Object
18 19 20 |
# File 'lib/fake_pipe/text_block.rb', line 18 def match_start_text(line) start_pattern && (self.start_match = start_pattern.match(line)) end |
#on_start_text(_match, _line) ⇒ Object
Override to do something interesting with the initial match or line
31 32 |
# File 'lib/fake_pipe/text_block.rb', line 31 def on_start_text(_match, _line) end |
#parse(_line) ⇒ Object
34 35 36 |
# File 'lib/fake_pipe/text_block.rb', line 34 def parse(_line) raise NotImplementedError, "#{self} doesn't implement `parse`." end |
#start_text? ⇒ Boolean
22 23 24 |
# File 'lib/fake_pipe/text_block.rb', line 22 def start_text? !start_match.nil? end |