Class: FakePipe::TextBlock

Inherits:
Object
  • Object
show all
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.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#delegateObject

Returns the value of attribute delegate.



12
13
14
# File 'lib/fake_pipe/text_block.rb', line 12

def delegate
  @delegate
end

#start_matchObject

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

#tableObject

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

Returns:

  • (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

Raises:

  • (NotImplementedError)


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

Returns:

  • (Boolean)


22
23
24
# File 'lib/fake_pipe/text_block.rb', line 22

def start_text?
  !start_match.nil?
end