Class: CheckPlease::PathSegmentMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/check_please/path_segment_matcher.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a, b) ⇒ PathSegmentMatcher

Returns a new instance of PathSegmentMatcher.



9
10
11
12
# File 'lib/check_please/path_segment_matcher.rb', line 9

def initialize(a, b)
  @a, @b = a, b
  @types = [ _type(a), _type(b) ].sort
end

Instance Attribute Details

#aObject (readonly)

Returns the value of attribute a.



8
9
10
# File 'lib/check_please/path_segment_matcher.rb', line 8

def a
  @a
end

#bObject (readonly)

Returns the value of attribute b.



8
9
10
# File 'lib/check_please/path_segment_matcher.rb', line 8

def b
  @b
end

#typesObject (readonly)

Returns the value of attribute types.



8
9
10
# File 'lib/check_please/path_segment_matcher.rb', line 8

def types
  @types
end

Class Method Details

.call(a, b) ⇒ Object



4
5
6
# File 'lib/check_please/path_segment_matcher.rb', line 4

def self.call(a,b)
  new(a,b).call
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
# File 'lib/check_please/path_segment_matcher.rb', line 14

def call
  return true             if either?(:splat)
  return a.name == b.name if both?(:plain)
  return a.key  == b.key  if key_and_key_value?

  false
end