Methods

Files

Class Index [+]

Quicksearch

CodeRay::CaseIgnoringWordList

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.

Public Class Methods

new(default = false, caching = false) click to toggle source

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.

     # 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, kind = true) click to toggle source

Add words to the list and associate them with kind.

     # 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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.