Class: Utopia::Path::Matcher::MatchData

Inherits:
Object
  • Object
show all
Defined in:
lib/utopia/path/matcher.rb

Overview

The result of matching against a Utopia::Path.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(named_parts, post_match) ⇒ MatchData

Initialize the named captures and unmatched path suffix.



21
22
23
24
# File 'lib/utopia/path/matcher.rb', line 21

def initialize(named_parts, post_match)
	@named_parts = named_parts
	@post_match = Path[post_match]
end

Instance Attribute Details

#named_partsObject (readonly)

Matched components by name.



27
28
29
# File 'lib/utopia/path/matcher.rb', line 27

def named_parts
  @named_parts
end

#post_matchObject (readonly)

Any remaining part past the end of the explicitly matched components.



30
31
32
# File 'lib/utopia/path/matcher.rb', line 30

def post_match
  @post_match
end

Instance Method Details

#[](key) ⇒ Object

Fetch a named capture.



35
36
37
# File 'lib/utopia/path/matcher.rb', line 35

def [] key
	@named_parts[key]
end

#namesObject

Return the named captures.



41
42
43
# File 'lib/utopia/path/matcher.rb', line 41

def names
	@named_parts.keys
end