Class: IntervalSkipListSpecHelper::ContainMarkers
- Defined in:
- lib/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb
Instance Attribute Summary collapse
-
#failure_message ⇒ Object
readonly
Returns the value of attribute failure_message.
Instance Method Summary collapse
-
#initialize(list, expected_markers) ⇒ ContainMarkers
constructor
A new instance of ContainMarkers.
- #matches?(target_range) ⇒ Boolean
Constructor Details
#initialize(list, expected_markers) ⇒ ContainMarkers
Returns a new instance of ContainMarkers.
26 27 28 29 |
# File 'lib/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb', line 26 def initialize(list, expected_markers) @list = list @expected_markers = expected_markers end |
Instance Attribute Details
#failure_message ⇒ Object (readonly)
Returns the value of attribute failure_message.
24 25 26 |
# File 'lib/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb', line 24 def @failure_message end |
Instance Method Details
#matches?(target_range) ⇒ Boolean
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb', line 31 def matches?(target_range) @target_range = target_range @target_range.each do |i| markers = @list.containing(i) @expected_markers.each do |expected_marker| unless markers.include?(expected_marker) @failure_message = "Expected #{expected_marker.inspect} to contain #{i}, but it doesn't. #{i} is contained by: #{markers.inspect}." return false end end markers.each do |marker| unless @expected_markers.include?(marker) @failure_message = "Did not expect #{marker.inspect} to contain #{i}. Only expected #{@expected_markers.inspect}." return false end end end true end |