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.



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

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.



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

def db=(value)
  @db = value
end

#specsObject (readonly)

Returns the value of attribute specs.



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

def specs
  @specs
end

Instance Method Details

#<=>(other) ⇒ Object



544
545
546
# File 'lib/bitclust/completion.rb', line 544

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

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



533
534
535
536
# File 'lib/bitclust/completion.rb', line 533

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

#class_nameObject



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

def class_name
  @specs.first.klass
end

#entryObject



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

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

#hashObject



540
541
542
# File 'lib/bitclust/completion.rb', line 540

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

#idstringObject



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

def idstring
  origin().to_s
end

#inherited_method?Boolean

Returns:

  • (Boolean)


561
562
563
# File 'lib/bitclust/completion.rb', line 561

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

#merge(other) ⇒ Object



548
549
550
# File 'lib/bitclust/completion.rb', line 548

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

#method_nameObject



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

def method_name
  @specs.first.method
end

#method_of_alias_class?Boolean

Returns:

  • (Boolean)


557
558
559
# File 'lib/bitclust/completion.rb', line 557

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

#nameObject



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

def name
  names().first
end

#namesObject



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

def names
  version = @db && @db.properties["version"]
  @specs.map {|spec| spec.display_name(version) }
end

#originObject



495
496
497
498
499
500
501
502
# File 'lib/bitclust/completion.rb', line 495

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

#original_nameObject



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

def original_name
  @idstring
end

#owned_method?Boolean

Returns:

  • (Boolean)


553
554
555
# File 'lib/bitclust/completion.rb', line 553

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