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



88
89
90
# File 'lib/hx/path.rb', line 88

def self.literal(literal_string)
  Pattern.new([literal_string])
end

.make_circumfix_re(prefix, suffix) ⇒ Object



169
170
171
172
173
# File 'lib/hx/path.rb', line 169

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



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/hx/path.rb', line 76

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