solunar 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,79 @@
1
+ class Solunar
2
+
3
+ VERSION = '0.0.1'
4
+ def version
5
+ "0.0.1"
6
+ end
7
+
8
+ def test
9
+ get_data("2017-05-01",200,29.2108,-81.0228,-5,1,0)
10
+ end
11
+
12
+ def get_data(date,count,lat,lon,tz_offset_hours,dst_offset_hours,military_time)
13
+ forecast = Array.new
14
+ res = generate(date,count,lat,lon,(tz_offset_hours*-60.0).to_i,(dst_offset_hours*60.0).to_i,military_time)
15
+ #Most data comes from the "generate" function, which lives in solunar.c
16
+ #Major feed times are currently defined as two hours starting at the moon underfoot and moon transit
17
+ #Minor feed times are one hour after moon rise and moon set
18
+ res.split(";").each do |line|
19
+ puts line
20
+ segments = line.split(",")
21
+ day = Hash.new
22
+ sun = Hash.new
23
+ moon = Hash.new
24
+ major_feed_times = Array.new
25
+ minor_feed_times = Array.new
26
+ sun[:rise] = segments[1].strip unless segments[1].strip == "NONE"
27
+ sun[:set] = segments[3].strip unless segments[3].strip == "NONE"
28
+ sun[:transit] = segments[2].strip unless segments[2].strip == "NONE"
29
+ moon[:rise] = segments[5].strip unless segments[5].strip == "NONE"
30
+ moon[:set] = segments[7].strip unless segments[7].strip == "NONE"
31
+ moon[:transit] = segments[6].strip unless segments[6].strip == "NONE"
32
+ day[:under_foot] = segments[4].strip unless segments[4].strip == "NONE"
33
+ unless moon[:rise].nil?
34
+ minor_feed_times << { start: moon[:rise], stop: add_hours(moon[:rise],1) }
35
+ end
36
+ unless moon[:set].nil?
37
+ minor_feed_times << { start: moon[:set], stop: add_hours(moon[:set],1) }
38
+ end
39
+ unless moon[:rise].nil? || moon[:set].nil? || moon[:rise].split(":").first.to_i < moon[:set].split(":").first.to_i
40
+ minor_feed_times.rotate!
41
+ end
42
+ unless moon[:transit].nil?
43
+ major_feed_times << { start: moon[:transit], stop: add_hours(moon[:transit],2) }
44
+ end
45
+ unless day[:under_foot].nil?
46
+ major_feed_times << { start: day[:under_foot], stop: add_hours(day[:under_foot],2) }
47
+ end
48
+ unless moon[:transit].nil? || day[:under_foot].nil? || moon[:transit].split(":").first.to_i < day[:under_foot].split(":").first.to_i
49
+ major_feed_times.rotate!
50
+ end
51
+ day[:date] = segments[0].strip
52
+ day[:days_since_new] = "Unknown"
53
+ day[:dayscale] = "Unknown"
54
+ day[:moon_illumination] = segments[12].strip
55
+ day[:moon_phase] = segments[10].strip
56
+ day[:moon] = moon
57
+ day[:sun] = sun
58
+ day[:major_feed_times] = major_feed_times
59
+ day[:minor_feed_times] = minor_feed_times
60
+ forecast<<day
61
+ end
62
+ forecast
63
+ end
64
+
65
+ def add_hours(str,num)
66
+ segs = str.split(":")
67
+ hour = segs[0].to_i
68
+ hour += num
69
+ hour += 24 if hour < 0
70
+ hour -= 24 if hour > 23
71
+ if hour > 9
72
+ return "#{hour.to_s}:#{segs[1]}:#{segs[2]}"
73
+ else
74
+ return "0#{hour.to_s}:#{segs[1]}:#{segs[2]}"
75
+ end
76
+ end
77
+
78
+ end
79
+ require 'solunar/solunar'
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solunar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - "\"Sullivan,"
8
+ - Nathan","Dawson,
9
+ - Rick"
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2016-10-24 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: A gem that wraps the C code from Rick Dawson that computes the sun and
16
+ moon times based on date and coordinates. Takes a series of arguments, and returns
17
+ a JSON of the hunting/fishing solunar forecast. While designed for hunting and fishing
18
+ applications, this may be useful to other apps that need solar or lunar data.
19
+ email: nathan@knockdownoutdoors.com
20
+ executables: []
21
+ extensions:
22
+ - ext/solunar/extconf.rb
23
+ extra_rdoc_files: []
24
+ files:
25
+ - ext/solunar/DST_Files/Test.txt
26
+ - ext/solunar/DST_Files/USA.txt
27
+ - ext/solunar/Data_Files/Test.bin
28
+ - ext/solunar/Data_Files/USA.bin
29
+ - ext/solunar/Source_Files/Moon.txt
30
+ - ext/solunar/Source_Files/Phase.TXT
31
+ - ext/solunar/Source_Files/Sun.txt
32
+ - ext/solunar/Source_Files/ilum_2016.txt
33
+ - ext/solunar/Source_Files/ilum_2017.txt
34
+ - ext/solunar/Source_Files/ilum_2018.txt
35
+ - ext/solunar/Source_Files/ilum_2019.txt
36
+ - ext/solunar/Source_Files/ilum_2020.txt
37
+ - ext/solunar/Source_Files/ilum_2021.txt
38
+ - ext/solunar/Source_Files/ilum_2022.txt
39
+ - ext/solunar/Source_Files/ilum_2023.txt
40
+ - ext/solunar/Source_Files/ilum_2024.txt
41
+ - ext/solunar/Source_Files/ilum_2025.txt
42
+ - ext/solunar/Source_Files/ilum_2026.txt
43
+ - ext/solunar/astrocon.h
44
+ - ext/solunar/extconf.rb
45
+ - ext/solunar/solunar.c
46
+ - lib/solunar.rb
47
+ homepage: https://github.com/KnockdownOutdoors/solunar
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 2.4.3
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Solunar Forecasting Gem
71
+ test_files: []