Class: NeuronCheckSystem::OrMatcher

Inherits:
MatcherBase show all
Defined in:
lib/neuroncheck/matcher.rb

Overview

OR条件。渡されたマッチャ複数のうち、どれか1つでも条件を満たせばOK

Instance Attribute Summary

Attributes inherited from MatcherBase

#declared_caller_locations

Instance Method Summary collapse

Methods inherited from MatcherBase

#get_error_message

Constructor Details

#initialize(child_expecteds, declared_caller_locations) ⇒ OrMatcher

Returns a new instance of OrMatcher.



171
172
173
174
# File 'lib/neuroncheck/matcher.rb', line 171

def initialize(child_expecteds, declared_caller_locations)
  @child_matchers = child_expecteds.map{|x| NeuronCheckSystem.get_appropriate_matcher(x, declared_caller_locations)}
  @declared_caller_locations = declared_caller_locations
end

Instance Method Details

#expected_captionObject



181
182
183
184
185
# File 'lib/neuroncheck/matcher.rb', line 181

def expected_caption
  captions = @child_matchers.map{|x| x.expected_caption}

  Utils.string_join_using_or_conjunction(captions)
end

#expected_short_captionObject



186
187
188
# File 'lib/neuroncheck/matcher.rb', line 186

def expected_short_caption
  '[' + @child_matchers.map{|x| x.expected_short_caption}.join(', ') + ']'
end

#match?(value, self_object) ⇒ Boolean

Returns:

  • (Boolean)


176
177
178
179
# File 'lib/neuroncheck/matcher.rb', line 176

def match?(value, self_object)
  # どれか1つにマッチすればOK
  @child_matchers.any?{|x| x.match?(value, self_object)}
end

#meta_info_as_jsonObject



190
191
192
# File 'lib/neuroncheck/matcher.rb', line 190

def meta_info_as_json
  super.update('child_matchers' => @child_matchers.map{|x| x.meta_info_as_json})
end