Class: ReFe::ClassTable

Inherits:
Object
  • Object
show all
Includes:
TraceUtils
Defined in:
lib/refe/database.rb

Instance Method Summary collapse

Methods included from TraceUtils

#trace

Constructor Details

#initialize(dbm, comp) ⇒ ClassTable

Returns a new instance of ClassTable.



177
178
179
180
# File 'lib/refe/database.rb', line 177

def initialize( dbm, comp )
  @dbm = dbm
  @comp = comp
end

Instance Method Details

#[](name) ⇒ Object



190
191
192
# File 'lib/refe/database.rb', line 190

def []( name )
  @dbm[name] or raise LookupError, "class not found: #{name}"
end

#[]=(name, content) ⇒ Object



194
195
196
197
# File 'lib/refe/database.rb', line 194

def []=( name, content )
  @comp.add name
  @dbm[name] = content
end

#classesObject



186
187
188
# File 'lib/refe/database.rb', line 186

def classes
  @comp.list
end

#complete(pattern) ⇒ Object

Raises:



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/refe/database.rb', line 199

def complete( pattern )
  list = @comp.expand(compile_pattern(pattern))
  raise CompletionError, "not match: #{pattern}" if list.empty?
  trace "class comp/1: list.size = #{list.size}"
  return list if list.size == 1

  list.each do |n|
    if n == pattern
      trace "class comp/2: exact match"
      return [n]
    end
  end

  trace "class comp: completion failed"
  list
end

#flushObject



182
183
184
# File 'lib/refe/database.rb', line 182

def flush
  @comp.flush
end