Module: Persistable::ClassMethods
- Included in:
- BestCompanies::Industry, BestCompanies::State
- Defined in:
- lib/best_companies/concerns/persistable.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.extended(base) ⇒ Object
15 16 17 |
# File 'lib/best_companies/concerns/persistable.rb', line 15 def self.extended(base) base.class_variable_set(:@@all,[]) end |
Instance Method Details
#check_input(input) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# 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 ⇒ Object
19 20 21 22 23 |
# 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 |