Class: Rosette::Core::PathMatcherFactory::PathNode
- Defined in:
- lib/rosette/core/path_matcher_factory.rb
Overview
Matches paths.
Instance Attribute Summary collapse
-
#path ⇒ String
readonly
The path to match.
Instance Method Summary collapse
-
#initialize(path) ⇒ PathNode
constructor
Creates a new path node.
-
#matches?(match_path) ⇒ Boolean
Determines if the given path matches
path. -
#to_s ⇒ String
Generates a string representation of this node.
Methods included from NodeOperatorFactory
Methods included from NodeFactory
#match_file_extension, #match_file_extensions, #match_path, #match_paths, #match_regex, #match_regexes
Constructor Details
#initialize(path) ⇒ PathNode
Creates a new path node.
275 276 277 |
# File 'lib/rosette/core/path_matcher_factory.rb', line 275 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ String (readonly)
Returns the path to match.
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/rosette/core/path_matcher_factory.rb', line 269 class PathNode < Node attr_reader :path # Creates a new path node. # # @param [String] path The path to match. def initialize(path) @path = path end # Determines if the given path matches +path+. # # @param [String] match_path The path to match. # @return [Boolean] true if +match_path+ matches +path+, false otherwise. # Matching is done by comparing the first +n+ characters of +match_path+ # to +path+, where +n+ is the number of characters in +path+. In other words, # if +path+ is "/path/to" and +match_path+ is '/path/to/foo.rb', this method # will return true. def matches?(match_path) match_path[0...path.size] == path end # Generates a string representation of this node. # # @return [String] def to_s "matches_path('#{path}')" end end |
Instance Method Details
#matches?(match_path) ⇒ Boolean
Determines if the given path matches path.
287 288 289 |
# File 'lib/rosette/core/path_matcher_factory.rb', line 287 def matches?(match_path) match_path[0...path.size] == path end |
#to_s ⇒ String
Generates a string representation of this node.
294 295 296 |
# File 'lib/rosette/core/path_matcher_factory.rb', line 294 def to_s "matches_path('#{path}')" end |