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.

[Source]

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

Public Instance methods

Add words to the list and associate them with kind.

[Source]

     # File lib/coderay/helpers/word_list.rb, line 114
114:   def add words, kind = true
115:     words.each do |word|
116:       self[word.downcase] = kind
117:     end
118:     self
119:   end

[Validate]