Class: Emojify
- Inherits:
-
Object
- Object
- Emojify
- Defined in:
- lib/emoji.rb
Instance Method Summary collapse
-
#initialize(city, weather_greeting, temp, weather_code) ⇒ Emojify
constructor
A new instance of Emojify.
- #output ⇒ Object
- #translate_city ⇒ Object
- #translate_greeting ⇒ Object
- #translate_temp ⇒ Object
- #translate_weather ⇒ Object
Constructor Details
#initialize(city, weather_greeting, temp, weather_code) ⇒ Emojify
Returns a new instance of Emojify.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/emoji.rb', line 4 def initialize(city,weather_greeting,temp,weather_code) @translations = { cities:{ "new york"=>"🇺🇸 🗽", "los angeles"=>"🇺🇸 🌊 🌴", "san francisco"=>"🇺🇸 🌁", "other"=>"🇺🇸" }, greetings:{ "2"=>"‼️ 🔌 💥", "3"=>"💦 💦 💦", "5"=>"💦 💦 💦", "6"=>"⛄️ ⁉️", "7"=>"🌀 💨 👒", "8"=>"😎 🌞 👍", "9"=>"🌋 💦 🔥 ✨" }, temps:{ "1"=>"1️⃣", "2"=>"2️⃣", "3"=>"3️⃣", "4"=>"4️⃣", "5"=>"5️⃣", "6"=>"6️⃣", "7"=>"7️⃣", "8"=>"8️⃣", "9"=>"9️⃣", "0"=>"0️⃣" }, codes:{ "thunderstorm"=>"⚡️ 💦", "rain"=>"☔️", "drizzle"=>"💦 💧", "snow"=>"❄️", "overcast clouds"=>"☁️", "clear sky"=>"☀️", "clouds"=>"⛅️", "breeze"=>"💨", "windy"=>"💨 💨 💨" } } @city = city @greeting = weather_greeting @temp = temp @code = weather_code end |
Instance Method Details
#output ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/emoji.rb', line 81 def output output = " 👋 😄 👍 📜 🌟 🌠 ✨ 💫 ‼️ 🚫 😖 ‼️ 🆗 🌍 🌎 🌏 📍 #{translate_city} 😲 👎 💥 🔫 💣 🔚 🔜 #{translate_greeting} #{translate_temp} 🌀 ➕ #{translate_weather} 🔮 💈 💸 💿 🚨 🎠 🎲 💃 ✨ 🍻 🍥 🐶 " end |
#translate_city ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/emoji.rb', line 51 def translate_city if !@translations[:cities].keys.include? @city.downcase @city = @translations[:cities]["other"] else @city = @translations[:cities][@city.downcase] end end |
#translate_greeting ⇒ Object
59 60 61 |
# File 'lib/emoji.rb', line 59 def translate_greeting @greeting = @translations[:greetings][@greeting] end |
#translate_temp ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/emoji.rb', line 63 def translate_temp t = [] @temp.split("").each do |num| t << @translations[:temps][num] end @temp = t.join(" ") end |
#translate_weather ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/emoji.rb', line 71 def translate_weather c = [] @translations[:codes].each do |key, val| if @code.include? key c << val end end @code = c.join(" ") end |