lib/journal-cli/checkin.rb in journal-cli-1.0.27 vs lib/journal-cli/checkin.rb in journal-cli-1.0.28

- old
+ new

@@ -134,15 +134,17 @@ def print_answer(prompt, type, key, data) return if data.nil? || !data.key?(key) || data[key].nil? case type - when /^(weather|forecast)/ + when /^(weather|forecast|moon)/ header prompt @output << case type when /current$/ data[key].current + when /moon$/ + "Moon phase: #{data[key].moon}" else data[key].to_markdown end when /^(int|num)/ @output << "#{prompt}: #{data[key]} " unless data[key].nil? @@ -172,10 +174,12 @@ data[k] = case k when /current$/ v.current when /forecast$/ data[k] = v.forecast + when /moon(_?phase)?$/ + data[k] = v.moon else data[k] = v.to_s end else data[k] = v @@ -256,20 +260,26 @@ journal.answers.each do |k, v| if v.is_a? Hash v.each do |key, value| result = case value.class.to_s when /Weather/ - if key =~ /current$/ - { - 'temp' => value.data[:temp], - 'condition' => value.data[:current_condition] - } - else - { - 'high' => value.data[:high], - 'low' => value.data[:low], - 'condition' => value.data[:condition] - } + case key + when /current$/ + { + 'temp' => value.data[:temp], + 'condition' => value.data[:current_condition] + } + when /moon(_?phase)?$/ + { + 'phase' => value.data[:moon_phase] + } + else + { + 'high' => value.data[:high], + 'low' => value.data[:low], + 'condition' => value.data[:condition], + 'moon_phase' => value.data[:moon_phase] + } end else value end if jk == k