Class: BitClust::SearchResult

Inherits:
Object
  • Object
show all
Includes:
DRb::DRbUndumped
Defined in:
lib/bitclust/server.rb,
lib/bitclust/completion.rb

Overview

Represents result of completion search. Has many SearchResult::Record.

Defined Under Namespace

Classes: Record

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, pattern, classes, records) ⇒ SearchResult

Returns a new instance of SearchResult.


408
409
410
411
412
413
# File 'lib/bitclust/completion.rb', line 408

def initialize(db, pattern, classes, records)
  @database = db
  @pattern = pattern
  @classes = classes
  @records = records
end

Instance Attribute Details

#classesObject (readonly)

Returns the value of attribute classes


417
418
419
# File 'lib/bitclust/completion.rb', line 417

def classes
  @classes
end

#databaseObject (readonly)

Returns the value of attribute database


415
416
417
# File 'lib/bitclust/completion.rb', line 415

def database
  @database
end

#patternObject (readonly)

Returns the value of attribute pattern


416
417
418
# File 'lib/bitclust/completion.rb', line 416

def pattern
  @pattern
end

#recordsObject (readonly)

Returns the value of attribute records


418
419
420
# File 'lib/bitclust/completion.rb', line 418

def records
  @records
end

Class Method Details

.empty(db, pattern) ⇒ Object


404
405
406
# File 'lib/bitclust/completion.rb', line 404

def SearchResult.empty(db, pattern)
  new(db, pattern, [], [])
end

Instance Method Details

#determined?Boolean

Returns:

  • (Boolean)

432
433
434
# File 'lib/bitclust/completion.rb', line 432

def determined?
  @records.size == 1
end

#each_record(&block) ⇒ Object


448
449
450
# File 'lib/bitclust/completion.rb', line 448

def each_record(&block)
  @records.sort.each(&block)
end

#fail?Boolean

Returns:

  • (Boolean)

424
425
426
# File 'lib/bitclust/completion.rb', line 424

def fail?
  @records.empty?
end

#inspectObject


420
421
422
# File 'lib/bitclust/completion.rb', line 420

def inspect
  "\#<BitClust::SearchResult @pattern=#{@pattern.inspect} @classes=#{@classes.inspect} @database=#{@database.inspect} @records=[#{record.inspect}, ...] >"
end

#nameObject


436
437
438
# File 'lib/bitclust/completion.rb', line 436

def name
  @records.first.name
end

#namesObject


440
441
442
# File 'lib/bitclust/completion.rb', line 440

def names
  @records.map {|rec| rec.names }.flatten
end

#recordObject


444
445
446
# File 'lib/bitclust/completion.rb', line 444

def record
  @records.first
end

#success?Boolean

Returns:

  • (Boolean)

428
429
430
# File 'lib/bitclust/completion.rb', line 428

def success?
  not @records.empty?
end