lib/rouge/lexer.rb
def guesses(info={})
        mimetype, filename, source = info.values_at(:mimetype, :filename, :source)
        lexers = registry.values.uniq
        total_size = lexers.size

        lexers = filter_by_mimetype(lexers, mimetype) if mimetype
        return lexers if lexers.size == 1

        lexers = filter_by_filename(lexers, filename) if filename
        return lexers if lexers.size == 1

        if source
          # If we're filtering against *all* lexers, we only use confident return
          # values from analyze_text.  But if we've filtered down already, we can trust
          # the analysis more.
          source_threshold = lexers.size < total_size ? 0 : 0.5
          return [best_by_source(lexers, source, source_threshold)].compact
        end

        []
      end
# Guess which lexer to use based on a hash of info.
#
# This accepts the same arguments as Lexer.guess, but will never throw
# an error.  It will return a (possibly empty) list of potential lexers
# to use.
Guess which lexer to use based on a hash of info.
This accepts the same arguments as Lexer.guess, but will never throw
an error.  It will return a (possibly empty) list of potential lexers
to use.
Guess which lexer to use based on a hash of info . This accepts the same arguments as Lexer . guess but will never throw an error . It will return a ( possibly empty ) list of potential lexers to use .
def guesses(info={})
        mimetype, filename, source = info.values_at(:mimetype, :filename, :source)
        lexers = registry.values.uniq
        total_size = lexers.size
        lexers = filter_by_mimetype(lexers, mimetype) if mimetype
        return lexers if lexers.size == 1
        lexers = filter_by_filename(lexers, filename) if filename
        return lexers if lexers.size == 1
        if source
          source_threshold = lexers.size < total_size ? 0 : 0.5
          return [best_by_source(lexers, source, source_threshold)].compact
        end
        []
      end
def guesses ( info = { } ) mimetype , filename , source = info . values_at ( :mimetype , :filename , :source ) lexers = registry . values . uniq total_size = lexers . size lexers = filter_by_mimetype ( lexers , mimetype ) if mimetype return lexers if lexers . size == 1 lexers = filter_by_filename ( lexers , filename ) if filename return lexers if lexers . size == 1 if source source_threshold = lexers . size < total_size ? 0 : 0.5 return [ best_by_source ( lexers , source , source_threshold ) ] . compact end [ ] end
Guess which lexer to use based on a hash of info.
Guess which lexer to use based on a hash of info .
# If we're filtering against *all* lexers, we only use confident return # values from analyze_text.  But if we've filtered down already, we can trust # the analysis more.
info