Class: Kiba::Uncommon::Transforms::RegexMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/kiba/uncommon/transforms/regex_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field, regex) ⇒ RegexMatcher

Returns a new instance of RegexMatcher.



14
15
16
17
# File 'lib/kiba/uncommon/transforms/regex_matcher.rb', line 14

def initialize(field, regex)
  @field = field
  @regex = regex
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



10
11
12
# File 'lib/kiba/uncommon/transforms/regex_matcher.rb', line 10

def field
  @field
end

#regexObject (readonly)

Returns the value of attribute regex.



11
12
13
# File 'lib/kiba/uncommon/transforms/regex_matcher.rb', line 11

def regex
  @regex
end

Instance Method Details

#process(row) ⇒ Object



20
21
22
# File 'lib/kiba/uncommon/transforms/regex_matcher.rb', line 20

def process(row)
  (regex =~ row.fetch(field)) ? row : nil
end