tempora 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a945f2d08e09bed694a289ec99717a591e348d780329fc3d3b9e6d1c57354a8
4
- data.tar.gz: a37eed5acf4ff7a0d4c423733b069e7afa195bf859742253c8474c47c3446d6f
3
+ metadata.gz: 459b4b52f06524a60b3a661aea7d7abdaff9893f92d1396b628e20003e26b985
4
+ data.tar.gz: 32bfd35efcbbb4342de00d19c1e08df914dcf85472ff576f745630d9d143d0dd
5
5
  SHA512:
6
- metadata.gz: 5e9b967909906cd6f2511c19e455904d53d4797692f635c04a14a4b1a5fe20cd42badafe74e9fb5f0ed1f8722f85836b5424b0b71c7acf67614209fdc6c8e902
7
- data.tar.gz: 35ef820b1e2133b6cb2af1b8d5ed80b86fd66f2fb6ef6112fd9fc44239e40c9a948bcd00208fd09776bec0b3884e8c9b98f76fea717bf0fe5a7a0a27555f8ab1
6
+ metadata.gz: b8eb1686ef5c168d8eb95a415012428e07703d2c531b8a424ab8fc4e2612f283c5295eb83a1fc00bb91d757e01262836a9cc9bfc1fcdc32f1a2ed30acebe8298
7
+ data.tar.gz: 6cdca41e418c828b85c31fb5140286b5585a49a776618d2d813bbd19a875d5c48657d80617a0de7d5da0420613fedeaf419d780c86a59acdc626bc56c545e8a5
data/lib/month.rb CHANGED
@@ -15,27 +15,27 @@ class Month
15
15
  end
16
16
 
17
17
  def id(seperator="-")
18
- "#{@year}#{seperator}#{@number.to_s.rjust(2, '0')}"
18
+ "#{year}#{seperator}#{number.to_s.rjust(2, '0')}"
19
19
  end
20
20
 
21
21
  def to_s
22
- "#{month_name} #{@year}"
22
+ "#{month_name} #{year}"
23
23
  end
24
24
 
25
25
  def month_name
26
- Date::MONTHNAMES[@number]
26
+ Date::MONTHNAMES[number]
27
27
  end
28
28
 
29
29
  def month_abbr
30
- Date::ABBR_MONTHNAMES[@number]
30
+ Date::ABBR_MONTHNAMES[number]
31
31
  end
32
32
 
33
33
  def next
34
- self.class.from(@start_date.next_month) # @start_date >> 1
34
+ self.class.from(start_date.next_month) # @start_date >> 1
35
35
  end
36
36
 
37
37
  def prev
38
- self.class.from(@start_date.prev_month) # @start_date << 1
38
+ self.class.from(start_date.prev_month) # @start_date << 1
39
39
  end
40
40
 
41
41
  def weeks
data/lib/quarter.rb CHANGED
@@ -17,30 +17,30 @@ class Quarter
17
17
  end
18
18
 
19
19
  def id(seperator="-")
20
- "#{@year}#{seperator}Q#{@number}"
20
+ "#{year}#{seperator}Q#{number}"
21
21
  end
22
22
 
23
23
  def to_s
24
- "Q#{@number} #{@year}"
24
+ "Q#{number} #{year}"
25
25
  end
26
26
 
27
27
  def next
28
- self.class.from(@start_date >> 3)
28
+ self.class.from(start_date >> 3)
29
29
  end
30
30
 
31
31
  def prev
32
- self.class.from(@start_date << 3)
32
+ self.class.from(start_date << 3)
33
33
  end
34
34
 
35
35
  alias_method :succ, :next
36
36
  alias_method :pred, :prev
37
37
 
38
38
  def months
39
- Month.from(@start_date)..Month.from(@start_date.next_month(2))
39
+ Month.from(start_date)..Month.from(end_date)
40
40
  end
41
41
 
42
42
  def weeks
43
- Week.from(@start_date)..Week.from(@end_date)
43
+ Week.from(start_date)..Week.from(end_date)
44
44
  end
45
45
 
46
46
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tempora
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/timeperiod.rb CHANGED
@@ -6,11 +6,11 @@ module TimePeriod
6
6
  attr_reader :start_date, :end_date, :year, :number
7
7
 
8
8
  def range
9
- @start_date..@end_date
9
+ start_date..end_date
10
10
  end
11
11
 
12
12
  def duration
13
- (@end_date - @start_date).to_i + 1
13
+ (end_date - start_date).to_i + 1
14
14
  end
15
15
 
16
16
  def days
@@ -32,14 +32,14 @@ module TimePeriod
32
32
  def intersection(other)
33
33
  return nil unless overlaps?(other)
34
34
 
35
- new_start = [@start_date, other.start_date].max
36
- new_end = [@end_date, other.end_date].min
35
+ new_start = [start_date, other.start_date].max
36
+ new_end = [end_date, other.end_date].min
37
37
 
38
38
  self.class.new(new_start, new_end)
39
39
  end
40
40
 
41
41
  def <=>(other)
42
- @start_date <=> other.start_date
42
+ start_date <=> other.start_date
43
43
  end
44
44
 
45
45
  alias_method :begin, :start_date
data/lib/week.rb CHANGED
@@ -14,19 +14,19 @@ class Week
14
14
  end
15
15
 
16
16
  def id(seperator="-")
17
- "#{@year}#{seperator}W#{format('%02d', @number)}"
17
+ "#{year}#{seperator}W#{format('%02d', number)}"
18
18
  end
19
19
 
20
20
  def to_s
21
- "Week #{@number}, #{@year}"
21
+ "Week #{number}, #{year}"
22
22
  end
23
23
 
24
24
  def next
25
- self.class.from(@start_date + 7)
25
+ self.class.from(start_date + 7)
26
26
  end
27
27
 
28
28
  def prev
29
- self.class.from(@start_date - 7)
29
+ self.class.from(start_date - 7)
30
30
  end
31
31
 
32
32
  alias_method :succ, :next
data/lib/year.rb CHANGED
@@ -15,27 +15,27 @@ class Year
15
15
  end
16
16
 
17
17
  def id
18
- @year
18
+ year
19
19
  end
20
20
 
21
21
  def to_s
22
- @year.to_s
22
+ year.to_s
23
23
  end
24
24
 
25
25
  def next
26
- self.class.new(@year + 1)
26
+ self.class.new(year + 1)
27
27
  end
28
28
 
29
29
  def prev
30
- self.class.new(@year - 1)
30
+ self.class.new(year - 1)
31
31
  end
32
32
 
33
33
  def months
34
- Month.new(@year, 1)..Month.new(@year, 12)
34
+ Month.new(year, 1)..Month.new(year, 12)
35
35
  end
36
36
 
37
37
  def weeks
38
- Week.new(@year, 1)..Week.new(@year, 52)
38
+ Week.from(start_date)..Week.from(end_date)
39
39
  end
40
40
 
41
41
  alias_method :succ, :next
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tempora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Power