work_day 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5dbab133cfa019db8bf4da785732cf062c5cd245
4
- data.tar.gz: d3c89c74daaced2e046c6790d6582c15703064fb
3
+ metadata.gz: 21d50aa093439ef7e32a14eb8c858b3f6a6e9d16
4
+ data.tar.gz: a41a3f371aa76ebfbf6eea560fd8a8e39ca92f54
5
5
  SHA512:
6
- metadata.gz: 56638a726e8d5193403fdf3cfe5f8ae6e531cd5e710b85bcf3701f1153be0bc5038b38a7f19b58444832e7e4bffe500cdcb22781bdb9328cbae4b56f1477f0e6
7
- data.tar.gz: 98279d2e4115ab8d3d8d924f9731c18c5d4ad4de35f9fa36c78da52b3cff59a1d7332dec60c23b2f3df0fe426f5684d96e7f5165107ebc0ea3fad8d525712f3c
6
+ metadata.gz: 58ebd92aee207b27534b5239427fb2c8afde29e51c0392f2c486637a4a930972856020a7ac650e804f2fd6020740d0a325d4e52b02cdb01e7170601875d04227
7
+ data.tar.gz: 6b97c360f0859aecb989fb745af5e31a67918c309c5e7897bcc8b87e665d02686652ba67dad100c3d84074f3b209e968b2407f234cb88b5a38f5d65faa669750
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class WorkDay
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
data/lib/work_day.rb CHANGED
@@ -5,11 +5,11 @@ require 'active_support'
5
5
  require 'active_support/core_ext'
6
6
 
7
7
  class WorkDay
8
- attr_reader :calendars
8
+ include Singleton
9
+ attr_accessor :calendars
9
10
 
10
- def initialize(calendars = ['brazil'])
11
- @calendars = calendars
12
- @holidays = {}
11
+ def self.calendars(calendars)
12
+ instance.calendars = calendars
13
13
  end
14
14
 
15
15
  def work_day?(date)
@@ -41,24 +41,27 @@ class WorkDay
41
41
  end
42
42
 
43
43
  def self.work_day?(date)
44
- WorkDay.new.work_day?(date)
44
+ WorkDay.instance.work_day?(date)
45
45
  end
46
46
 
47
47
  def self.last_until(date, days = 0)
48
- WorkDay.new.last_until(date, days)
48
+ WorkDay.instance.last_until(date, days)
49
49
  end
50
50
 
51
51
  def self.next_after(date, days = 1)
52
- WorkDay.new.next_after(date, days)
52
+ WorkDay.instance.next_after(date, days)
53
53
  end
54
54
 
55
55
  def self.between(start_date, end_date)
56
- WorkDay.new.between(start_date, end_date)
56
+ WorkDay.instance.between(start_date, end_date)
57
57
  end
58
58
 
59
59
  private
60
60
 
61
61
  def holidays_in(year)
62
- @holidays[year] ||= Holiday.new(calendars).in(year)
62
+ @calendars ||= ['brazil']
63
+ @holidays ||= {}
64
+ @holidays[calendars] ||= {}
65
+ @holidays[calendars][year] ||= Holiday.new(calendars).in(year)
63
66
  end
64
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: work_day
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adriano Bacha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-27 00:00:00.000000000 Z
11
+ date: 2018-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  version: '0'
97
97
  requirements: []
98
98
  rubyforge_project:
99
- rubygems_version: 2.6.8
99
+ rubygems_version: 2.4.8
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: work days