Class: BitClust::SearchResult::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/bitclust/completion.rb

Overview

Wraps an Entry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, spec, origin = nil, entry = nil) ⇒ Record

Returns a new instance of Record.


454
455
456
457
458
459
# File 'lib/bitclust/completion.rb', line 454

def initialize(db, spec, origin = nil, entry = nil)
  @db = db
  @specs = [spec]
  @origin = origin
  @entry = entry
end

Instance Attribute Details

#db=(value) ⇒ Object (writeonly)

Sets the attribute db

Parameters:

  • value

    the value to set the attribute db to.


461
462
463
# File 'lib/bitclust/completion.rb', line 461

def db=(value)
  @db = value
end

#specsObject (readonly)

Returns the value of attribute specs


462
463
464
# File 'lib/bitclust/completion.rb', line 462

def specs
  @specs
end

Instance Method Details

#<=>(other) ⇒ Object


511
512
513
# File 'lib/bitclust/completion.rb', line 511

def <=>(other)
  entry() <=> other.entry
end

#==(other) ⇒ Object Also known as: eql?


501
502
503
# File 'lib/bitclust/completion.rb', line 501

def ==(other)
  @idstring == other.idstring
end

#class_nameObject


489
490
491
# File 'lib/bitclust/completion.rb', line 489

def class_name
  @specs.first.klass
end

#entryObject


477
478
479
# File 'lib/bitclust/completion.rb', line 477

def entry
  @entry ||= @db.get_method(origin())
end

#hashObject


507
508
509
# File 'lib/bitclust/completion.rb', line 507

def hash
  @hash ||= idstring().hash
end

#idstringObject


473
474
475
# File 'lib/bitclust/completion.rb', line 473

def idstring
  origin().to_s
end

#inherited_method?Boolean

Returns:

  • (Boolean)

528
529
530
# File 'lib/bitclust/completion.rb', line 528

def inherited_method?
  !owned_method?() && !method_of_alias_class?()
end

#merge(other) ⇒ Object


515
516
517
# File 'lib/bitclust/completion.rb', line 515

def merge(other)
  @specs |= other.specs
end

#method_nameObject


493
494
495
# File 'lib/bitclust/completion.rb', line 493

def method_name
  @specs.first.method
end

#method_of_alias_class?Boolean

Returns:

  • (Boolean)

524
525
526
# File 'lib/bitclust/completion.rb', line 524

def method_of_alias_class?
  @entry.klass.aliases.any?{|aliasclass| aliasclass.name?(class_name())}
end

#nameObject


481
482
483
# File 'lib/bitclust/completion.rb', line 481

def name
  names().first
end

#namesObject


485
486
487
# File 'lib/bitclust/completion.rb', line 485

def names
  @specs.map {|spec| spec.display_name }
end

#originObject


464
465
466
467
468
469
470
471
# File 'lib/bitclust/completion.rb', line 464

def origin
  @origin ||=
      begin
        spec = @specs.first
        c = @db.fetch_class(spec.klass)
        MethodSpec.parse(c.match_entry(spec.type, spec.method))
      end
end

#original_nameObject


497
498
499
# File 'lib/bitclust/completion.rb', line 497

def original_name
  @idstring
end

#owned_method?Boolean

Returns:

  • (Boolean)

520
521
522
# File 'lib/bitclust/completion.rb', line 520

def owned_method?
  @specs.any? {|spec| spec.klass == origin().klass }
end