class Ragol::Matchers

Attributes

negatives[R]
regexps[R]
tags[R]

Public Class Methods

new(tags, negate, regexp) click to toggle source
# File lib/ragol/matchers.rb, line 15
def initialize tags, negate, regexp
  @tags = tags
  @negatives = negate
  @regexps = regexp
end

Public Instance Methods

match_type?(arg) click to toggle source
# File lib/ragol/matchers.rb, line 33
def match_type? arg
  case 
  when tm = tag_match?(arg)
    [ :tag_match, tm ]
  when nm = negative_match?(arg)
    [ :negative_match, nm ]
  when rm = regexp_match?(arg)
    [ :regexp_match, rm ]
  else
    nil
  end
end
name() click to toggle source
# File lib/ragol/matchers.rb, line 46
def name
  @name ||= begin
              if @tags
                if longtag = @tags.elements.find { |t| t[0, 2] == '--' }
                  longtag.sub(%r{^--}, '')
                else
                  @tags.elements[0][1 .. -1]
                end
              elsif @regexps
                @regexps.elements[0].to_s
              end
            end
end
negative_match?(arg) click to toggle source
# File lib/ragol/matchers.rb, line 25
def negative_match? arg
  @negatives and @negatives.match? arg
end
regexp_match?(arg) click to toggle source
# File lib/ragol/matchers.rb, line 29
def regexp_match? arg
  @regexps and @regexps.match? arg
end
tag_match?(arg) click to toggle source
# File lib/ragol/matchers.rb, line 21
def tag_match? arg
  @tags and @tags.match? arg
end
to_s() click to toggle source
# File lib/ragol/matchers.rb, line 60
def to_s
  [ @tags, @regexps ].compact.collect { |x| x.to_s }.join(' ')
end