Class: ReFe::FunctionTable
- Inherits:
-
Object
- Object
- ReFe::FunctionTable
- Includes:
- TraceUtils
- Defined in:
- lib/refe/database.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, content) ⇒ Object
- #complete(words) ⇒ Object
- #flush ⇒ Object
-
#initialize(dbm, comp) ⇒ FunctionTable
constructor
A new instance of FunctionTable.
Methods included from TraceUtils
Constructor Details
#initialize(dbm, comp) ⇒ FunctionTable
Returns a new instance of FunctionTable.
489 490 491 492 |
# File 'lib/refe/database.rb', line 489 def initialize( dbm, comp ) @dbm = dbm @comp = comp end |
Instance Method Details
#[](name) ⇒ Object
498 499 500 501 |
# File 'lib/refe/database.rb', line 498 def []( name ) @dbm[*name.split(/_/)] or raise LookupError, "function not found: #{name}" end |
#[]=(name, content) ⇒ Object
503 504 505 506 |
# File 'lib/refe/database.rb', line 503 def []=( name, content ) @comp.add name @dbm[*name.split(/_/)] = content end |
#complete(words) ⇒ Object
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
# File 'lib/refe/database.rb', line 508 def complete( words ) pattern = normalize(words) items = @comp.(compile_pattern(pattern)) trace "function: comp/1: items.size = #{items.size}" raise CompletionError, "not match: #{words.join(' ')}" if items.empty? return items if items.size == 1 words = pattern.split(/_/) alt1 = items.select {|func| tmp = func.split(/_/) (tmp.size == words.size) and (tmp[-1] == words[-1]) } trace "function: comp/2: alt1.size = #{alt1.size}" return alt1 if alt1.size == 1 items end |
#flush ⇒ Object
494 495 496 |
# File 'lib/refe/database.rb', line 494 def flush @comp.flush end |