Class: TestBench::Session::Substitute::Path
- Inherits:
-
Object
- Object
- TestBench::Session::Substitute::Path
- Defined in:
- lib/test_bench/session/substitute/path.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #copy(receiver) ⇒ Object
- #eql?(compare) ⇒ Boolean (also: #==)
- #match?(*segments, segment) ⇒ Boolean
- #pop_segment(compare_segment = nil) ⇒ Object (also: #pop)
- #push_segment(segment) ⇒ Object (also: #push)
Instance Attribute Details
#segments ⇒ Object
5 6 7 |
# File 'lib/test_bench/session/substitute/path.rb', line 5 def segments @segments ||= [] end |
Instance Method Details
#copy(receiver) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/test_bench/session/substitute/path.rb', line 41 def copy(receiver) path = self.class.new segments.each do |segment| path << segment end receiver.path = path path end |
#eql?(compare) ⇒ Boolean Also known as: ==
52 53 54 55 56 57 58 |
# File 'lib/test_bench/session/substitute/path.rb', line 52 def eql?(compare) if compare.is_a?(self.class) segments == compare.segments else false end end |
#match?(*segments, segment) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/test_bench/session/substitute/path.rb', line 10 def match?(*segments, segment) if not segment == self.segments.last return false end segment_iterator = self.segments.to_enum control_segments = [*segments, segment] control_segments.all? do |control_segment| begin next_segment = segment_iterator.next end until next_segment == control_segment true rescue StopIteration false end end |
#pop_segment(compare_segment = nil) ⇒ Object Also known as: pop
36 37 38 |
# File 'lib/test_bench/session/substitute/path.rb', line 36 def pop_segment(compare_segment=nil) segments.pop end |
#push_segment(segment) ⇒ Object Also known as: push
30 31 32 |
# File 'lib/test_bench/session/substitute/path.rb', line 30 def push_segment(segment) segments << segment end |