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.


327
328
329
330
331
332
333
# File 'lib/bitclust/searcher.rb', line 327

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


335
336
337
# File 'lib/bitclust/searcher.rb', line 335

def database
  @database
end

Instance Method Details

#show_class(cs) ⇒ Object


337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/bitclust/searcher.rb', line 337

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


373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# File 'lib/bitclust/searcher.rb', line 373

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


355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/bitclust/searcher.rb', line 355

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