require 'csv'
require 'date'
items =[]
CSV.foreach('lucky_item.csv',headers: true) do |row|
  items << { item: row['item'], advice: row['advice']}
end

 puts "あなたの名前を入れてね。漢字でもひらがなでもローマ字でもOK!ただし、どれを選ぶかで占いの結果が変わるよ＼(^o^)／"
 name = gets.chomp
 puts "あなたの生年月日を入れてね(例2010年1月30日生まれ→2010-01-30):"
 birthday = gets.chomp

 today = Date.today
 birth_date = Date.parse(birthday)
 name_code_sum = name.chars.map(&:ord).sum

 index = (birth_date.year + birth_date.month + birth_date.day + today.year + today.month + today.day + name_code_sum) % items.size

  puts "#{name}さんの今日のラッキーアイテムは: #{items[index][:item]}"
  puts "#{items[index][:advice]}"    
  puts "#{items[index][:knowledge]}"

  if today.month == birth_date.month && today.day == birth_date.day
    puts "お誕生日おめでとう!  ハッピーバースデー!!"
    puts " "
    puts <<-ART
 i i i i i i i i i
  |^^^^^^^^^^^^^|
  |^^^^^^^^^^^^^|
\_________________/
 |^^^^^^^^^^^^^^^|
|~~~~~~~~~~~~~~~~~|
===================
|__HAPPY BIRTHDAY__|

ART
  end
  puts <<-ART 
||                 
||H     H       A      V       V   EEEEE            A            NN    N     IIIIIII     CCCCCC    EEEEE        DDDDDD         A         Y   Y    !    !
||H     H      A A      V     V    E               A A           N N   N        I       C          E            D     D       A A         Y Y     !    !
||HHHHHHH     AAAAA      V   V     EEEEE          AAAAA          N  N  N        I      C           EEEEE        D      D     AAAAA         Y      !    !
||H     H    A     A      V V      E             A     A         N   N N        I       C          E            D     D     A     A        Y           
||H     H   A       A      V       EEEEE        A       A        N    NN     IIIIIII     CCCCCC    EEEEE        DDDDDD     A       A      YYY     !    !
||
ART

