Class: CheckPlease::PathSegment
- Inherits:
-
Object
- Object
- CheckPlease::PathSegment
- Includes:
- Reification
- Defined in:
- lib/check_please/path_segment.rb
Constant Summary collapse
- KEY_EXPR =
%r{ ^ \: # a literal colon ( # capture key [^\:]+ # followed by one or more things that aren't colons ) # end capture key $ }x
- KEY_VAL_EXPR =
%r{ ^ ( # capture key [^=]+ # stuff (just not an equal sign) ) # end capture key \= # an equal sign ( # capture key value [^=]+ # stuff (just not an equal sign) ) # end capture key value $ }x
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#key_value ⇒ Object
readonly
Returns the value of attribute key_value.
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name = nil) ⇒ PathSegment
constructor
A new instance of PathSegment.
- #key_expr? ⇒ Boolean
- #key_val_expr? ⇒ Boolean
- #match?(other_segment_or_string) ⇒ Boolean
- #splat? ⇒ Boolean
Methods included from Reification
Constructor Details
#initialize(name = nil) ⇒ PathSegment
Returns a new instance of PathSegment.
31 32 33 34 35 36 37 38 39 40 41 |
# 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 |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
28 29 30 |
# File 'lib/check_please/path_segment.rb', line 28 def key @key end |
#key_value ⇒ Object (readonly)
Returns the value of attribute key_value.
28 29 30 |
# File 'lib/check_please/path_segment.rb', line 28 def key_value @key_value end |
#name ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute name.
28 29 30 |
# File 'lib/check_please/path_segment.rb', line 28 def name @name end |
Instance Method Details
#key_expr? ⇒ Boolean
43 44 45 |
# File 'lib/check_please/path_segment.rb', line 43 def key_expr? name.match?(KEY_EXPR) end |
#key_val_expr? ⇒ Boolean
47 48 49 |
# File 'lib/check_please/path_segment.rb', line 47 def key_val_expr? name.match?(KEY_VAL_EXPR) end |
#match?(other_segment_or_string) ⇒ Boolean
51 52 53 54 |
# 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? ⇒ Boolean
56 57 58 |
# File 'lib/check_please/path_segment.rb', line 56 def splat? name == '*' end |