Module: USNO::Eclipse::Solar::Eclipses

Defined in:
lib/usno/eclipse/solar/eclipses.rb

Class Method Summary collapse

Class Method Details

.allObject

As reminders



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/usno/eclipse/solar/eclipses.rb', line 36

def self.all
  %w{
    2008 February 7 (Annular)
    2008 August 1 (Total)
    2009 January 26 (Annular)
    2009 July 21-22 (Total)
    2010 January 15 (Annular)
    2010 July 11 (Total)
    2011 January 4 (Partial)
    2011 June 1 (Partial)
    2011 July 1 (Partial)
    2011 November 25 (Partial)
    2012 May 20-21 (Annular)
    2012 November 13-14 (Total)
    2013 May 9-10 (Annular)
    2013 November 3 (Total)
    2014 April 29 (Annular)
    2014 October 23 (Partial)
    2015 March 20 (Total)
    2015 September 13 (Partial)
    2016 March 8-9 (Total)
    2016 September 1 (Annular)
    2017 February 26 (Annular)
    2017 August 21 (Total)
  }
end

.by_key_or_value(kv) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/usno/eclipse/solar/eclipses.rb', line 5

def self.by_key_or_value(kv)
  hash.has_value? kv and return kv

  hash.fetch(formatted_date(kv)) {
    raise "No known solar eclipse at the provided time #{kv} - hint, try USNO::Eclipse::Solar::Eclipses.all"
  }.to_s
end

.fetch(kv) ⇒ Object



13
14
15
# File 'lib/usno/eclipse/solar/eclipses.rb', line 13

def self.fetch(kv)
  by_key_or_value(kv)
end

.formatted_date(date) ⇒ Object



31
32
33
# File 'lib/usno/eclipse/solar/eclipses.rb', line 31

def self.formatted_date(date)
  date.strftime("%Y%-m%-d")
end

.hashObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/usno/eclipse/solar/eclipses.rb', line 17

def self.hash
  {
    "200827"  => 12008, "20111125" => 42011, "2015320"  => 12015,
    "200881"  => 22008, "2012520"  => 12012, "2015913"  => 22015,
    "2009126" => 12009, "2012521"  => 12012, "201638"   => 12016,
    "2009721" => 22009, "20121113" => 22012, "201639"   => 12016,
    "2009722" => 22009, "20121114" => 22012, "201691"   => 22016,
    "2010115" => 12010, "201359"   => 12013, "2017226"  => 12017,
    "2010711" => 22010, "2013510"  => 12013, "2017821"  => 22017,
    "201114"  => 12011, "2013113"  => 22013, "20141023" => 22014,
    "201161"  => 22011, "2014429"  => 12014, "201171"   => 32011
  }
end