module FishingTideFormat
Public Instance Methods
Source
# File lib/fishing_tide_format.rb, line 29 def format_day_line(day, index) moon = day[:moon_phase] || "unknown moon" summary = "#{index + 1}. #{day[:date].strftime('%a %d %b')} โ #{moon}, #{format('%.1f', day[:run])} m run" events = day[:events] return summary if events.nil? || events.empty? "#{summary} ยท #{format_events(events)}" end
Source
# File lib/fishing_tide_format.rb, line 17 def format_event(event) kind = event[:type].to_s time = format_time_local(event[:time_local]) height = format("%.1f", event[:height]) "#{kind} #{time} #{height} m" end
Source
# File lib/fishing_tide_format.rb, line 24 def format_events(events) sorted = events.sort_by { |event| event[:time_local].to_s } sorted.map { |event| format_event(event) }.join(" ยท ") end
Source
# File lib/fishing_tide_format.rb, line 13 def format_time_local(iso) Time.parse(iso.to_s).strftime("%l:%M%P").strip end