Class: Expect::SeparatedPattern
Overview
Instance Attribute Summary collapse
-
#separator ⇒ Object
Returns the value of attribute separator.
Instance Method Summary collapse
- #===(line) ⇒ Object
-
#initialize(message, separator = ',') ⇒ SeparatedPattern
constructor
A new instance of SeparatedPattern.
Constructor Details
#initialize(message, separator = ',') ⇒ SeparatedPattern
Returns a new instance of SeparatedPattern.
75 76 77 78 |
# File 'lib/carat/expect.rb', line 75 def initialize(, separator = ',') @message = @separator = separator end |
Instance Attribute Details
#separator ⇒ Object
Returns the value of attribute separator.
73 74 75 |
# File 'lib/carat/expect.rb', line 73 def separator @separator end |
Instance Method Details
#===(line) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/carat/expect.rb', line 80 def ===(line) = @message.dup # Iterate through each field to make sure it matches. When # we find a match, delete that field so we never check it # again. for field in fields do .each_index do |index| if [index] === field then .delete_at(index) end end end # If there are no more fields, then we deleted all of them, # and we got a match return .length == 0 end |