Module: Rosette::Core::PathMatcherFactory::NodeFactory
- Included in:
- Rosette::Core::PathMatcherFactory, Node
- Defined in:
- lib/rosette/core/path_matcher_factory.rb
Overview
Provides common methods for creating nodes.
Instance Method Summary collapse
-
#match_file_extension(extension) ⇒ FileExtensionNode
Creates a FileExtensionNode.
-
#match_file_extensions(extensions) ⇒ FileExtensionNode, OrNode
Creates a bunch of FileExtensionNodes combined using a logical “or”.
-
#match_path(path) ⇒ PathNode
Creates a PathNode.
-
#match_paths(paths) ⇒ PathNode, OrNode
Creates a bunch of PathNodes combined using a logical “or”.
-
#match_regex(regex) ⇒ RegexNode
Creates a RegexNode.
-
#match_regexes(regexes) ⇒ RegexNode, OrNode
Creates a bunch of RegexNodes combined using a logical “or”.
Instance Method Details
#match_file_extension(extension) ⇒ FileExtensionNode
Creates a FileExtensionNode.
54 55 56 |
# File 'lib/rosette/core/path_matcher_factory.rb', line 54 def match_file_extension(extension) FileExtensionNode.new(extension) end |
#match_file_extensions(extensions) ⇒ FileExtensionNode, OrNode
Creates a bunch of FileExtensionNodes combined using a logical “or”.
67 68 69 70 71 72 |
# File 'lib/rosette/core/path_matcher_factory.rb', line 67 def match_file_extensions(extensions) Array(extensions).inject(nil) do |node, extension| new_node = match_file_extension(extension) node ? node.or(new_node) : new_node end end |
#match_path(path) ⇒ PathNode
Creates a PathNode.
78 79 80 |
# File 'lib/rosette/core/path_matcher_factory.rb', line 78 def match_path(path) PathNode.new(path) end |
#match_paths(paths) ⇒ PathNode, OrNode
Creates a bunch of PathNodes combined using a logical “or”.
90 91 92 93 94 95 |
# File 'lib/rosette/core/path_matcher_factory.rb', line 90 def match_paths(paths) Array(paths).inject(nil) do |node, path| new_node = match_path(path) node ? node.or(new_node) : new_node end end |
#match_regex(regex) ⇒ RegexNode
Creates a RegexNode.
101 102 103 |
# File 'lib/rosette/core/path_matcher_factory.rb', line 101 def match_regex(regex) RegexNode.new(regex) end |
#match_regexes(regexes) ⇒ RegexNode, OrNode
Creates a bunch of RegexNodes combined using a logical “or”.
113 114 115 116 117 118 |
# File 'lib/rosette/core/path_matcher_factory.rb', line 113 def match_regexes(regexes) Array(regexes).inject(nil) do |node, regex| new_node = match_regex(regex) node ? node.or(new_node) : new_node end end |