Class: Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/collectors.rb

Overview

class for sc

Instance Method Summary collapse

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

#matchesObject



17
18
19
# File 'lib/collectors.rb', line 17

def matches
  @bin
end