class BaseChip::Menu

Public Instance Methods

list_line(string,object) click to toggle source
# 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) click to toggle source
# 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