Class: Shaf::Command::Test::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/shaf/command/test/filter.rb

Constant Summary collapse

None =
Filter.new('.*.rb')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(criteria) ⇒ Filter

Returns a new instance of Filter.



9
10
11
12
13
# File 'lib/shaf/command/test/filter.rb', line 9

def initialize(criteria)
  pattern, *lines = criteria.split(':')
  @lines = lines.map(&:to_i)
  @pattern = Regexp.new(pattern)
end

Instance Attribute Details

#linesObject (readonly)

Returns the value of attribute lines.



7
8
9
# File 'lib/shaf/command/test/filter.rb', line 7

def lines
  @lines
end

#patternObject (readonly)

Returns the value of attribute pattern.



7
8
9
# File 'lib/shaf/command/test/filter.rb', line 7

def pattern
  @pattern
end

Instance Method Details

#match?(file) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/shaf/command/test/filter.rb', line 15

def match?(file)
  pattern.match? file
end