Class: GitStatistics::RegexMatcher
- Inherits:
-
Object
- Object
- GitStatistics::RegexMatcher
- Defined in:
- lib/git_statistics/regex_matcher.rb
Instance Attribute Summary collapse
-
#expected_change_count ⇒ Object
readonly
Returns the value of attribute expected_change_count.
-
#regex ⇒ Object
readonly
Returns the value of attribute regex.
Instance Method Summary collapse
- #if_matches(line) ⇒ Object
-
#initialize(regex, expected_change_count) ⇒ RegexMatcher
constructor
A new instance of RegexMatcher.
- #scan(line) ⇒ Object
Constructor Details
#initialize(regex, expected_change_count) ⇒ RegexMatcher
Returns a new instance of RegexMatcher.
5 6 7 8 |
# File 'lib/git_statistics/regex_matcher.rb', line 5 def initialize(regex, expected_change_count) @regex = regex @expected_change_count = expected_change_count end |
Instance Attribute Details
#expected_change_count ⇒ Object (readonly)
Returns the value of attribute expected_change_count.
4 5 6 |
# File 'lib/git_statistics/regex_matcher.rb', line 4 def expected_change_count @expected_change_count end |
#regex ⇒ Object (readonly)
Returns the value of attribute regex.
4 5 6 |
# File 'lib/git_statistics/regex_matcher.rb', line 4 def regex @regex end |
Instance Method Details
#if_matches(line) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/git_statistics/regex_matcher.rb', line 14 def if_matches(line) changes = self.scan(line) if changes && changes.size == expected_change_count yield changes else {} end end |
#scan(line) ⇒ Object
10 11 12 |
# File 'lib/git_statistics/regex_matcher.rb', line 10 def scan(line) line.scan(regex).first || [] end |