class CheckPlease::PathSegment
Constants
- KEY_EXPR
- KEY_VAL_EXPR
Attributes
key[R]
key_value[R]
name[R]
to_s[R]
Public Class Methods
new(name = nil)
click to toggle source
# File lib/check_please/path_segment.rb, line 31 def initialize(name = nil) @name = name.to_s.strip case @name when "", /\s/ # blank or has any whitespace raise InvalidPathSegment, "#{name.inspect} is not a valid #{self.class} name" end parse_key_and_value freeze end
Public Instance Methods
key_expr?()
click to toggle source
# File lib/check_please/path_segment.rb, line 43 def key_expr? name.match?(KEY_EXPR) end
key_val_expr?()
click to toggle source
# File lib/check_please/path_segment.rb, line 47 def key_val_expr? name.match?(KEY_VAL_EXPR) end
match?(other_segment_or_string)
click to toggle source
# File lib/check_please/path_segment.rb, line 51 def match?(other_segment_or_string) other = reify(other_segment_or_string) PathSegmentMatcher.call(self, other) end
splat?()
click to toggle source
# File lib/check_please/path_segment.rb, line 56 def splat? name == '*' end
Private Instance Methods
parse_key_and_value()
click to toggle source
# File lib/check_please/path_segment.rb, line 62 def parse_key_and_value case name when KEY_EXPR @key = $1 when KEY_VAL_EXPR @key, @key_value = $1, $2 else # :nothingtodohere: end end