lib/lita/handlers/onewheel_moonphase.rb in lita-onewheel-moonphase-2.0.0 vs lib/lita/handlers/onewheel_moonphase.rb in lita-onewheel-moonphase-2.0.1
- old
+ new
@@ -7,22 +7,31 @@
:moon,
command: true,
help: {'moon [location]' => 'Get Moon phase data'}
# 🌑🌛
- # emoonjis = %w(🌚🌘🌗🌔🌕🌖🌓🌒)
def moon(response)
location = get_location(response)
-
moon = get_data(location)
# today = Time.now
rise_time = Time.parse moon['moondata']['rise']
set_time = Time.parse moon['moondata']['set']
- reply = "#{get_moonmoji(moon['moondata']['fracillum'], moon['moondata']['curphase'])} Moon phase #{moon['moondata']['fracillum']}, #{moon['moondata']['curphase']}. "
+ emoonjis = {
+ 'New Moon' => '🌚',
+ 'Waning Crescent' => '🌘',
+ 'Last Quarter' => '🌗',
+ 'Waxing Gibbous' => '🌔',
+ 'Full Moon' => '🌕',
+ 'Waning Gibbous' => '🌖',
+ 'First Quarter' => '🌓',
+ 'Waxing Crescent' => '🌒'
+ }
+
+ reply = "#{emoonjis[moon['moondata']['curphase']]} Moon phase #{moon['moondata']['fracillum']}, #{moon['moondata']['curphase']}. "
reply += "Rise: #{rise_time.strftime("%H:%M")} Set: #{set_time.strftime('%H:%M')}"
Lita.logger.debug "Replying with #{reply}"
response.reply reply
end
@@ -42,31 +51,31 @@
location
end
# Next step, determine waxing or waning.
- def get_moonmoji(percent_full, phase)
- moonmoji = ''
- waning = false
+ # def get_moonmoji(percent_full, phase)
+ # moonmoji = ''
+ # waning = false
- if phase.match /waning/i
- waning = true
- end
-
- case percent_full.sub('%', '').to_i
- when 0..1
- moonmoji = '🌚'
- when 2..32
- moonmoji = waning ? '🌘' : '🌒'
- when 33..62
- moonmoji = phase.match(/last/i) ? '🌗' : '🌓'
- when 63..90
- moonmoji = waning ? '🌖' : '🌔'
- when 91..100
- moonmoji = '🌕'
- end
- moonmoji
- end
+ # if phase.match /waning/i
+ # waning = true
+ # end
+ #
+ # case percent_full.sub('%', '').to_i
+ # when 0..1
+ # moonmoji = '🌚'
+ # when 2..32
+ # moonmoji = waning ? '🌘' : '🌒'
+ # when 33..62
+ # moonmoji = phase.match(/last/i) ? '🌗' : '🌓'
+ # when 63..90
+ # moonmoji = waning ? '🌖' : '🌔'
+ # when 91..100
+ # moonmoji = '🌕'
+ # end
+ # moonmoji
+ # end
Lita.register_handler(self)
end
end
end