rahu_yama_time 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rahu_yama_time.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Sriram Kumar
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # RahuYamaTime
2
+
3
+ Get the Raahukaalam, Yamakantam and Gulikai for a given day or date
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rahu_yama_time'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rahu_yama_time
18
+
19
+ ## Usage
20
+
21
+ Pass the date(as String or DateTime object) or day(as String or FixNum object) for which you need the Raahukaalam, Yamakantam and Gulikai timings. For the whole timetable, pass the String 'week'.
22
+
23
+ For example:
24
+ 1. Get the object for the class of function to be called: timetable = RahuYamaTime::TimeTableCalculator.new
25
+ 2. Call the function 'get_rahukalam_yamagandam_gulikai_timetable' with the following valid parameters to get the timetable.
26
+ 2.1 timetable.get_rahukalam_yamagandam_gulikai_timetable("12-12-2012") # => A hash for the day '12.12.12' having all rahukalam, yamagandam and gulikai timings.
27
+ 2.2 timetable.get_rahukalam_yamagandam_gulikai_timetable(DateTime.parse("12-Dec-2012")) # => Same output as 2.1.
28
+ 2.3 timetable.get_rahukalam_yamagandam_gulikai_timetable("Wednesday") # => Same output as 2.1.
29
+ 2.4 timetable.get_rahukalam_yamagandam_gulikai_timetable(3) # => Same output as 2.1. 0 indicates Sunday, 1 indicates Monday and so on.
30
+ 2.5 timetable.get_rahukalam_yamagandam_gulikai_timetable(3, "rahukalam") # => A hash for rahukalam on Wednesday.
31
+ 2.6 timetable.get_rahukalam_yamagandam_gulikai_timetable(3, "yamagandam") # => A hash for yamagandam on Wednesday.
32
+ 2.7 timetable.get_rahukalam_yamagandam_gulikai_timetable(3, "gulikai") # => A hash for gulikai on Wednesday.
33
+ 2.8 timetable.get_rahukalam_yamagandam_gulikai_timetable("week") # => An array of hashes for the whole week's timetable.
34
+ 2.9 timetable.get_rahukalam_yamagandam_gulikai_timetable("week", "rahukalam") # => An array of hashes for the rahukalam of the whole week.
35
+ 2.10 timetable.get_rahukalam_yamagandam_gulikai_timetable("week", "yamagandam") # => An array of hashes for the yamagandam of the whole week.
36
+ 2.11 timetable.get_rahukalam_yamagandam_gulikai_timetable("week", "gulikai") # => An array of hashes for the gulikai of the whole week.
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,70 @@
1
+ require "rahu_yama_time/version"
2
+
3
+ module RahuYamaTime
4
+ class TimeTableCalculator
5
+
6
+ def initialize()
7
+ # Initializing the main data
8
+ @timings = []
9
+ @timings[0]={ rahukalam: {from: "16.30", to: "18.00"}, yamagandam: {from: "12.00", to: "13.30"}, gulikai: {from: "15.00", to: "16.30"} }
10
+ @timings[1]={ rahukalam: {from: "07.30", to: "09.00"}, yamagandam: {from: "10.30", to: "12.00"}, gulikai: {from: "13.30", to: "15.00"} }
11
+ @timings[2]={ rahukalam: {from: "15.00", to: "16.30"}, yamagandam: {from: "09.00", to: "10.30"}, gulikai: {from: "12.00", to: "13.30"} }
12
+ @timings[3]={ rahukalam: {from: "12.00", to: "13.30"}, yamagandam: {from: "07.30", to: "09.00"}, gulikai: {from: "10.30", to: "12.00"} }
13
+ @timings[4]={ rahukalam: {from: "13.30", to: "15.00"}, yamagandam: {from: "06.00", to: "07.30"}, gulikai: {from: "09.00", to: "10.30"} }
14
+ @timings[5]={ rahukalam: {from: "10.30", to: "12.00"}, yamagandam: {from: "15.00", to: "16.30"}, gulikai: {from: "07.30", to: "09.00"} }
15
+ @timings[6]={ rahukalam: {from: "09.00", to: "10.30"}, yamagandam: {from: "13.30", to: "15.00"}, gulikai: {from: "06.00", to: "07.30"} }
16
+ end
17
+
18
+ def get_rahukalam_yamagandam_gulikai_timetable(param, options = nil)
19
+
20
+ day = nil
21
+
22
+ begin
23
+ # Analyzing the input parameter and converting it into day if the request is not for a whole week
24
+ case param.class.to_s
25
+ when DateTime.to_s
26
+ day = param.wday
27
+ when Fixnum.to_s
28
+ if param < 7 && param >= 0
29
+ day = param
30
+ else
31
+ raise "Improper day format in numbers"
32
+ end
33
+ when String.to_s
34
+ if param.downcase != 'week'
35
+ day = DateTime.parse(param).wday
36
+ end
37
+ end
38
+
39
+ if [DateTime.to_s, Fixnum.to_s].include?(param.class.to_s)
40
+ if day.nil?
41
+ raise "Improper input parameter"
42
+ end
43
+ # Returning the requested data based on the option
44
+ (options.nil?) ? @timings[day] : @timings[day][options.downcase.to_sym]
45
+ else
46
+ if param.downcase != 'week'
47
+ if day.nil?
48
+ raise "Improper input parameter"
49
+ end
50
+ # Returning the requested data based on the option
51
+ (options.nil?) ? @timings[day] : @timings[day][options.downcase.to_sym]
52
+ else
53
+ # Returning the requested rahukalam/yamagandam/gulikai data alone for whole week based on the option
54
+ if options.nil?
55
+ @timings
56
+ else
57
+ custom_timings = []
58
+ @timings.each do |preferred_time|
59
+ custom_timings << preferred_time[options.downcase.to_sym]
60
+ end
61
+ custom_timings
62
+ end
63
+ end
64
+ end
65
+ rescue => format_exception
66
+ format_exception.message
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,3 @@
1
+ module RahuYamaTime
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rahu_yama_time/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "rahu_yama_time"
8
+ gem.version = RahuYamaTime::VERSION
9
+ gem.authors = ["SriramK89"]
10
+ gem.email = ["ksrirambecse@gmail.com"]
11
+ gem.description = %q{Get the Raahukaalam, Yamakantam and Gulikai for a given day or date}
12
+ gem.summary = %q{Pass the date(as String or DateTime object) or day(as String or FixNum object) for which you need the Raahukaalam, Yamakantam and Gulikai timings. For the whole timetable, pass the String 'week'.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rahu_yama_time
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - SriramK89
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Get the Raahukaalam, Yamakantam and Gulikai for a given day or date
15
+ email:
16
+ - ksrirambecse@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/rahu_yama_time.rb
27
+ - lib/rahu_yama_time/version.rb
28
+ - rahu_yama_time.gemspec
29
+ homepage: ''
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.24
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: Pass the date(as String or DateTime object) or day(as String or FixNum object)
53
+ for which you need the Raahukaalam, Yamakantam and Gulikai timings. For the whole
54
+ timetable, pass the String 'week'.
55
+ test_files: []