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.



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

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.



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

def db=(value)
  @db = value
end

#specsObject (readonly)

Returns the value of attribute specs.



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

def specs
  @specs
end

Instance Method Details

#<=>(other) ⇒ Object



513
514
515
# File 'lib/bitclust/completion.rb', line 513

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

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



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

def ==(other)
  return false if self.class != other.class
  @idstring == other.idstring
end

#class_nameObject



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

def class_name
  @specs.first.klass
end

#entryObject



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

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

#hashObject



509
510
511
# File 'lib/bitclust/completion.rb', line 509

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

#idstringObject



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

def idstring
  origin().to_s
end

#inherited_method?Boolean

Returns:

  • (Boolean)


530
531
532
# File 'lib/bitclust/completion.rb', line 530

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

#merge(other) ⇒ Object



517
518
519
# File 'lib/bitclust/completion.rb', line 517

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

#method_nameObject



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

def method_name
  @specs.first.method
end

#method_of_alias_class?Boolean

Returns:

  • (Boolean)


526
527
528
# File 'lib/bitclust/completion.rb', line 526

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

#nameObject



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

def name
  names().first
end

#namesObject



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

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

#originObject



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

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



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

def original_name
  @idstring
end

#owned_method?Boolean

Returns:

  • (Boolean)


522
523
524
# File 'lib/bitclust/completion.rb', line 522

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