Sha256: 1e493a3bd29f0eb05745795316cacef72999b3ba4f0b9acfc684200a6bff7f00

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

Contents

# CLI Controller
class CanadianMergers::CLI
  attr_accessor :year, :month

  def call
    menu
    list_mergers
    goodbye
  end

  def menu
    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

  def list_mergers
    puts "Merger reviews concluded for the period of #{@month.capitalize}, #{@year}:"
    @merger_list = CanadianMergers::MergerList.table(@year, @month)
  end

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
canadian_mergers-0.1.0 lib/canadian_mergers/cli.rb