Class: BitClust::TerminalView

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(compiler, opts) ⇒ TerminalView

Returns a new instance of TerminalView.



377
378
379
380
381
382
383
# File 'lib/bitclust/searcher.rb', line 377

def initialize(compiler, opts)
  @compiler = compiler
  @describe_all = opts[:describe_all]
  @line = opts[:line]
  @encoding = opts[:encoding]
  @database = nil
end

Instance Attribute Details

#databaseObject

Returns the value of attribute database.



385
386
387
# File 'lib/bitclust/searcher.rb', line 385

def database
  @database
end

Instance Method Details

#show_class(cs) ⇒ Object



387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/bitclust/searcher.rb', line 387

def show_class(cs)
  if cs.size == 1
    if @line
      print_names [cs.first.label]
    else
      describe_class cs.first
    end
  else
    if @describe_all
      cs.sort.each do |c|
        describe_class c
      end
    else
      print_names cs.map {|c| c.labels }.flatten
    end
  end
end

#show_function(fs) ⇒ Object



423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/bitclust/searcher.rb', line 423

def show_function(fs)
  if fs.size == 1
    if @line
      print_names [fs.first.label]
    else
      describe_function fs.first
    end
  else
    if @describe_all
      fs.sort.each do |f|
        describe_function f
      end
    else
      print_names fs.map {|f| f.label }
    end
  end
end

#show_method(result) ⇒ Object



405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/bitclust/searcher.rb', line 405

def show_method(result)
  if result.determined?
    if @line
      print_names result.names
    else
      describe_method result.record
    end
  else
    if @describe_all
      result.each_record do |rec|
        describe_method rec
      end
    else
      print_names result.names
    end
  end
end