Class: BitClust::SearchResult::Record
- Defined in:
- lib/bitclust/completion.rb
Overview
Wraps an Entry.
Instance Attribute Summary collapse
-
#db ⇒ Object
writeonly
Sets the attribute db.
-
#specs ⇒ Object
readonly
Returns the value of attribute specs.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #class_name ⇒ Object
- #entry ⇒ Object
- #hash ⇒ Object
- #idstring ⇒ Object
- #inherited_method? ⇒ Boolean
-
#initialize(db, spec, origin = nil, entry = nil) ⇒ Record
constructor
A new instance of Record.
- #merge(other) ⇒ Object
- #method_name ⇒ Object
- #method_of_alias_class? ⇒ Boolean
- #name ⇒ Object
- #names ⇒ Object
- #origin ⇒ Object
- #original_name ⇒ Object
- #owned_method? ⇒ Boolean
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
462 463 464 |
# File 'lib/bitclust/completion.rb', line 462 def db=(value) @db = value end |
#specs ⇒ Object (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_name ⇒ Object
490 491 492 |
# File 'lib/bitclust/completion.rb', line 490 def class_name @specs.first.klass end |
#entry ⇒ Object
478 479 480 |
# File 'lib/bitclust/completion.rb', line 478 def entry @entry ||= @db.get_method(origin()) end |
#hash ⇒ Object
509 510 511 |
# File 'lib/bitclust/completion.rb', line 509 def hash @hash ||= idstring().hash end |
#idstring ⇒ Object
474 475 476 |
# File 'lib/bitclust/completion.rb', line 474 def idstring origin().to_s end |
#inherited_method? ⇒ 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_name ⇒ Object
494 495 496 |
# File 'lib/bitclust/completion.rb', line 494 def method_name @specs.first.method end |
#method_of_alias_class? ⇒ 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 |
#name ⇒ Object
482 483 484 |
# File 'lib/bitclust/completion.rb', line 482 def name names().first end |
#names ⇒ Object
486 487 488 |
# File 'lib/bitclust/completion.rb', line 486 def names @specs.map {|spec| spec.display_name } end |
#origin ⇒ Object
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_name ⇒ Object
498 499 500 |
# File 'lib/bitclust/completion.rb', line 498 def original_name @idstring end |
#owned_method? ⇒ Boolean
522 523 524 |
# File 'lib/bitclust/completion.rb', line 522 def owned_method? @specs.any? {|spec| spec.klass == origin().klass } end |