Class: Gherkin::Formatter::LineFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/gherkin/formatter/line_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(lines) ⇒ LineFilter

Returns a new instance of LineFilter.



4
5
6
# File 'lib/gherkin/formatter/line_filter.rb', line 4

def initialize(lines)
  @lines = lines
end

Instance Method Details

#eval(tags, names, ranges) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/gherkin/formatter/line_filter.rb', line 8

def eval(tags, names, ranges)
  ranges.detect do |range|
    @lines.detect do |line|
      range.include?(line)
    end
  end
end

#filter_table_body_rows(rows) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/gherkin/formatter/line_filter.rb', line 16

def filter_table_body_rows(rows)
  body = rows.to_a[1..-1].select do |row|
    @lines.detect do |line|
      row.line == line
    end
  end
  [rows[0]] + body
end