class Emojify
Public Class Methods
new(city,weather_greeting,temp,weather_code)
click to toggle source
# 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
Public Instance Methods
output()
click to toggle source
# File lib/emoji.rb, line 81 def output output = " 👋 😄 👍 📜 🌟 🌠 ✨ 💫 ‼️ 🚫 😖 ‼️ 🆗 🌍 🌎 🌏 📍 #{translate_city} 😲 👎 💥 🔫 💣 🔚 🔜 #{translate_greeting} #{translate_temp} 🌀 ➕ #{translate_weather} 🔮 💈 💸 💿 🚨 🎠 🎲 💃 ✨ 🍻 🍥 🐶 " end
translate_city()
click to toggle source
# 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()
click to toggle source
# File lib/emoji.rb, line 59 def translate_greeting @greeting = @translations[:greetings][@greeting] end
translate_temp()
click to toggle source
# 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()
click to toggle source
# 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