module Persistable::ClassMethods

Public Class Methods

extended(base) click to toggle source
# File lib/best_companies/concerns/persistable.rb, line 15
def self.extended(base)
 base.class_variable_set(:@@all,[])
end

Public Instance Methods

check_input(input) click to toggle source
# File lib/best_companies/concerns/persistable.rb, line 25
def check_input(input)
 if input.match(/\d{1,}/) && input.to_i.between?(1,self.all.size)
  self.all.sort{|a,b| a.name <=> b.name}[(input.to_i)-1].companies.each{|v|BestCompanies::CLI.see_company(v)}
 elsif input == "menu"
 BestCompanies::CLI.ask_user
 else
  BestCompanies::CLI.reject_input
  self.check_input(BestCompanies::CLI.get_input)
 end
end
list() click to toggle source
# File lib/best_companies/concerns/persistable.rb, line 19
def list
 puts "-----------------------------------------"
 output = self.all.sort{|a,b| a.name <=> b.name}
 output.each.with_index(1){|v,i|puts "#{i}: #{v.name}".colorize(:red)}
end