Class: CanadianMergers::CLI
- Inherits:
-
Object
- Object
- CanadianMergers::CLI
- Defined in:
- lib/canadian_mergers/cli.rb
Overview
CLI Controller
Instance Attribute Summary collapse
-
#month ⇒ Object
Returns the value of attribute month.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
Instance Attribute Details
#month ⇒ Object
Returns the value of attribute month.
3 4 5 |
# File 'lib/canadian_mergers/cli.rb', line 3 def month @month end |
#year ⇒ Object
Returns the value of attribute year.
3 4 5 |
# File 'lib/canadian_mergers/cli.rb', line 3 def year @year end |
Instance Method Details
#call ⇒ Object
5 6 7 8 9 |
# File 'lib/canadian_mergers/cli.rb', line 5 def call list_mergers goodbye end |
#goodbye ⇒ Object
27 28 29 30 31 |
# File 'lib/canadian_mergers/cli.rb', line 27 def goodbye puts 'Would you like to convert this table to CSV? (Y/n)' input = gets.strip CanadianMergers::MergerList.to_csv(@year, @month) if /y/i =~ input end |
#list_mergers ⇒ Object
22 23 24 25 |
# File 'lib/canadian_mergers/cli.rb', line 22 def list_mergers puts "Merger reviews concluded for the period of #{@month.capitalize}, #{@year}:" @merger_list = CanadianMergers::MergerList.table(@year, @month) end |
#menu ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/canadian_mergers/cli.rb', line 11 def until @year.to_i.between?(2012, Date.today.year) puts 'Please enter the year you would like to access:' @year = gets.strip end until Date::MONTHNAMES.include?(@month.to_s.capitalize) puts 'Please enter the month you would like to access (January - December)' @month = gets.strip.downcase end end |