Class CodeRay::CaseIgnoringWordList
In: lib/coderay/helpers/word_list.rb
Parent: WordList

A CaseIgnoringWordList is like a WordList, only that keys are compared case-insensitively.

Ignoring the text case is realized by sending the downcase message to all keys.

Caching usually makes a CaseIgnoringWordList faster, but it has to be activated explicitely.

Methods

add   new  

Public Class methods

Creates a new case-insensitive WordList with default as default value.

You can activate caching to store the results for every [] request. This speeds up subsequent lookups for the same word, but also uses memory.

[Source]

     # File lib/coderay/helpers/word_list.rb, line 103
103:   def initialize default = false, caching = false
104:     if caching
105:       super(default, false) do |h, k|
106:         h[k] = h.fetch k.downcase, default
107:       end
108:     else
109:       super(default, false)
110:       extend Uncached
111:     end
112:   end

Public Instance methods

Add words to the list and associate them with kind.

[Source]

     # File lib/coderay/helpers/word_list.rb, line 121
121:   def add words, kind = true
122:     words.each do |word|
123:       self[word.downcase] = kind
124:     end
125:     self
126:   end

[Validate]