class Rouge::Lexers::VimL
Public Class Methods
keywords()
click to toggle source
# File lib/rouge/lexers/viml.rb, line 15 def self.keywords load Pathname.new(__FILE__).dirname.join('viml/keywords.rb') self.keywords end
Public Instance Methods
find_likely_mapping(mapping, word)
click to toggle source
binary search through the mappings to find the one that's likely to actually work.
# File lib/rouge/lexers/viml.rb, line 75 def find_likely_mapping(mapping, word) min = 0 max = mapping.size until max == min mid = (max + min) / 2 cmp, _ = mapping[mid] case word <=> cmp when 1 # too low min = mid + 1 when -1 # too high max = mid when 0 # just right, abort! return mapping[mid] end end mapping[max - 1] end
mapping_contains?(mapping, word)
click to toggle source
# File lib/rouge/lexers/viml.rb, line 66 def mapping_contains?(mapping, word) shortest, longest = find_likely_mapping(mapping, word) shortest and word.start_with?(shortest) and longest and longest.start_with?(word) end