Class: DataMaps::When::Regex

Inherits:
Base show all
Defined in:
lib/data_maps/when/regex.rb

Overview

Condition to check for an regular expression

Since:

  • 0.0.1

Instance Attribute Summary collapse

Attributes inherited from Executable

#@option, #option

Instance Method Summary collapse

Methods inherited from Executable

#initialize, valid_collection?

Constructor Details

This class inherits a constructor from DataMaps::Executable

Instance Attribute Details

#@regexObject (readonly)

the given regex

Returns:

  • (Object)

    the current value of @regex



7
8
9
# File 'lib/data_maps/when/regex.rb', line 7

def @regex
  @@regex
end

#regexObject (readonly)

Since:

  • 0.0.1



8
9
10
# File 'lib/data_maps/when/regex.rb', line 8

def regex
  @regex
end

Instance Method Details

#after_initializeObject

After initialize callback

Since:

  • 0.0.1



11
12
13
# File 'lib/data_maps/when/regex.rb', line 11

def after_initialize
  @regex = Regexp.new(option)
end

#execute(data) ⇒ Object

The check method to evaluate condition on given data

Parameters:

  • data (mixed)

Since:

  • 0.0.1



18
19
20
# File 'lib/data_maps/when/regex.rb', line 18

def execute(data)
  !!@regex.match(data)
end