Module: Hx::Path
- Defined in:
- lib/hx/path.rb
Defined Under Namespace
Modules: Connective, Selector
Classes: All, AssumeCircumfix, Conjunction, Disjunction, ElideCircumfix, Negation, Pattern
Constant Summary
collapse
- ALL =
All.new
Class Method Summary
collapse
Class Method Details
.literal(literal_string) ⇒ Object
97
98
99
|
# File 'lib/hx/path.rb', line 97
def self.literal(literal_string)
Pattern.new([literal_string])
end
|
.make_circumfix_re(prefix, suffix) ⇒ Object
178
179
180
181
182
|
# File 'lib/hx/path.rb', line 178
def self.make_circumfix_re(prefix, suffix)
quoted_prefix = Regexp.quote(prefix.to_s)
quoted_suffix = Regexp.quote(suffix.to_s)
@circumfix_re = /^#{quoted_prefix}(.*)#{quoted_suffix}$/
end
|
.parse_pattern(pattern_string) ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/hx/path.rb', line 85
def self.parse_pattern(pattern_string)
tokens = []
pattern_string.scan(/(\*\*?|[^*]+)/) do |token,|
tokens << case token
when "**"; :doublestar
when "*"; :star
else; token
end
end
Pattern.new(tokens)
end
|