Class: ReFe::MethodTable
- Inherits:
-
Object
- Object
- ReFe::MethodTable
- Includes:
- MethodCompletion
- Defined in:
- lib/refe/database.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(spec, content) ⇒ Object
- #complete(c, t, m) ⇒ Object
- #flush ⇒ Object
-
#initialize(dbm, comp) ⇒ MethodTable
constructor
A new instance of MethodTable.
- #instance_methods_of(c, include_super) ⇒ Object
- #key?(name) ⇒ Boolean
- #singleton_methods_of(c, include_super) ⇒ Object
Methods included from TraceUtils
Constructor Details
#initialize(dbm, comp) ⇒ MethodTable
Returns a new instance of MethodTable.
396 397 398 399 |
# File 'lib/refe/database.rb', line 396 def initialize( dbm, comp ) @dbm = dbm @comp = comp end |
Instance Method Details
#[](name) ⇒ Object
421 422 423 424 425 |
# File 'lib/refe/database.rb', line 421 def []( name ) c, t, m = name.split(/([\.\#])/, 2) @dbm[c + t, m] or raise LookupError, "method not found: #{name}" end |
#[]=(spec, content) ⇒ Object
427 428 429 430 431 432 433 434 435 |
# File 'lib/refe/database.rb', line 427 def []=( spec, content ) c, t, m = spec.split(/([\.\#])/, 2) raise "missing class: #{spec.inspect}" unless c raise "missing type: #{spec.inspect}" unless t raise "missing method: #{spec.inspect}" unless m @dbm[c + t, m] = content @comp.add spec content end |
#complete(c, t, m) ⇒ Object
442 443 444 |
# File 'lib/refe/database.rb', line 442 def complete( c, t, m ) complete0(self, @comp, c, t, m) end |
#flush ⇒ Object
401 402 403 |
# File 'lib/refe/database.rb', line 401 def flush @comp.flush end |
#instance_methods_of(c, include_super) ⇒ Object
413 414 415 416 417 418 419 |
# File 'lib/refe/database.rb', line 413 def instance_methods_of( c, include_super ) if include_super @comp.(/\A@#{c}#/).map {|n| n.sub(/\A@[\w:]+#/, '') } else @comp.(/\A#{c}#/).map {|n| n.sub(/\A[\w:]+#/, '') } end end |
#key?(name) ⇒ Boolean
437 438 439 440 |
# File 'lib/refe/database.rb', line 437 def key?( name ) c, t, m = name.split(/([\.\#])/, 2) @dbm[c + t, m] ? true : false end |
#singleton_methods_of(c, include_super) ⇒ Object
405 406 407 408 409 410 411 |
# File 'lib/refe/database.rb', line 405 def singleton_methods_of( c, include_super ) if include_super @comp.(/\A@#{c}\./).map {|n| n.sub(/\A@[\w:]+\./, '') } else @comp.(/\A#{c}\./).map {|n| n.sub(/\A[\w:]+\./, '') } end end |