Class: AsciiDataTools::RecordType::Field::RegexpConstraint

Inherits:
Constraint
  • Object
show all
Defined in:
lib/ascii-data-tools/record_type/field.rb

Instance Method Summary collapse

Constructor Details

#initialize(regexp_that_must_match) ⇒ RegexpConstraint

Returns a new instance of RegexpConstraint.



150
151
152
# File 'lib/ascii-data-tools/record_type/field.rb', line 150

def initialize(regexp_that_must_match)
  @regexp_that_must_match = regexp_that_must_match
end

Instance Method Details

#extend_regexp_string_for_matching(regexp_string) ⇒ Object



154
155
156
# File 'lib/ascii-data-tools/record_type/field.rb', line 154

def extend_regexp_string_for_matching(regexp_string)
  regexp_string + @regexp_that_must_match.source
end

#satisfied_by?(string) ⇒ Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/ascii-data-tools/record_type/field.rb', line 158

def satisfied_by?(string)
  string =~ @regexp_that_must_match
end

#to_sObject



162
163
164
# File 'lib/ascii-data-tools/record_type/field.rb', line 162

def to_s
  "=~ #{@regexp_that_must_match.inspect}"
end