Class: BaseChip::Menu

Inherits:
Object
  • Object
show all
Includes:
Reporting
Defined in:
lib/base_chip/menu.rb

Overview

< Thor

Direct Known Subclasses

GeneratorMenu, InstallMenu, ListMenu, TopMenu

Instance Method Summary collapse

Methods included from Reporting

included

Instance Method Details

#list_line(string, object) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/base_chip/menu.rb', line 50

def list_line(string,object)
  array = (string.is_a? Array) ? string : [string]

  if self.options.show
    object.configure
    tmp = object
    self.options.show.split(/\./).each do |fun|
      fault("Object of type #{tmp.respond_to?(:class_string) ? tmp.class_string : tmp.class} does not have a data element #{fun.inspect}") unless tmp.respond_to?(fun)
      tmp = tmp.send(fun)
    end
    array << tmp
  end

  if array.size == 1
    puts string
  else
    @table << array
  end
end

#smart_print(string, object, *array) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/base_chip/menu.rb', line 22

def smart_print(string, object, *array)
  if @pattern == nil
    list_line(string,object)
    return
  end
  if @pattern.is_a? Regexp
    if string.is_a? Array
      array += string
    else
      array << string
    end
    array.each do |str|
      if str =~ @pattern
        list_line(string,object)
        return
      end
    end
  else
    if array.include? @pattern
      list_line(string,object)
      return
    end
    if string == @pattern
      list_line(string,object)
      return
    end
  end
end