Class: BritishSuntimesAgent
- Inherits:
-
BritishSuntimes
- Object
- BritishSuntimes
- BritishSuntimesAgent
- Defined in:
- lib/british_suntimes.rb
Instance Attribute Summary
Attributes inherited from BritishSuntimes
#bst_end, #bst_start, #shortest_day, #to_dx, #to_h
Instance Method Summary collapse
Methods inherited from BritishSuntimes
Constructor Details
This class inherits a constructor from BritishSuntimes
Instance Method Details
#longest_day ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/british_suntimes.rb', line 100 def longest_day() d = super() days = (Date.parse(d) - Date.today).to_i sunrise, sunset = to_dx().to_h[d] t1 = Time.parse(d + ' ' + sunrise) t2 = Time.parse(d + ' ' + sunset) su = Subunit.new(units={minutes:60, hours:60}, seconds: (t2 - t1).to_i) duration = su.to_s omit: [:seconds] d2 = Date.parse(d) day = d2.strftime("#{d2.day.ordinal} %B") s = d2.humanize msg = s[0].upcase + s[1..-1] + ", the longest day of the year, #%s \ will enjoy %s of sunshine. The sun will rise at %sam \ and set at %spm." % [@location, duration, t1.strftime("%-I:%M"), \ t2.strftime("%-I:%M")] end |