Class: Rouge::Guessers::Disambiguation::Disambiguator

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/rouge/guessers/disambiguation.rb

Instance Method Summary collapse

Methods included from Util

#get_source, #test_glob

Constructor Details

#initialize(patterns, &decider) ⇒ Disambiguator

Returns a new instance of Disambiguator.



48
49
50
51
# File 'lib/rouge/guessers/disambiguation.rb', line 48

def initialize(patterns, &decider)
  @patterns = patterns
  @decider = decider
end

Instance Method Details

#decide!(guesser) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/rouge/guessers/disambiguation.rb', line 53

def decide!(guesser)
  out = guesser.instance_eval(&@decider)
  case out
  when Array then out
  when nil then nil
  else [out]
  end
end

#match?(filename) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/rouge/guessers/disambiguation.rb', line 62

def match?(filename)
  @patterns.any? { |p| test_glob(p, filename) }
end