Class: Collector
- Inherits:
-
Object
- Object
- Collector
- Defined in:
- lib/collectors.rb
Overview
class for sc
Instance Method Summary collapse
-
#initialize(pattern) ⇒ Collector
constructor
A new instance of Collector.
- #input(string) ⇒ Object
-
#ismatch(string) ⇒ Object
tests for a match.
- #matches ⇒ Object
Constructor Details
#initialize(pattern) ⇒ Collector
Returns a new instance of Collector.
4 5 6 7 |
# File 'lib/collectors.rb', line 4 def initialize(pattern) @pattern = pattern @bin = [] end |
Instance Method Details
#input(string) ⇒ Object
8 9 10 11 12 |
# File 'lib/collectors.rb', line 8 def input(string) if string =~ @pattern @bin << string end end |
#ismatch(string) ⇒ Object
tests for a match
14 15 16 |
# File 'lib/collectors.rb', line 14 def ismatch(string) (string =~ @pattern) ? true : false end |
#matches ⇒ Object
17 18 19 |
# File 'lib/collectors.rb', line 17 def matches @bin end |