scoppie 0.0.1 → 0.0.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/scope.rb +1 -0
  3. data/lib/scope_methods.rb +11 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3c3decb5df0a490f569339dc29dc39d09a549ff
4
- data.tar.gz: 4ba0a2d09bf589e56778bc085dbeaf6e09c9515c
3
+ metadata.gz: 48e4573a157b2efd5632f9ca75c7ff3f3fa537a5
4
+ data.tar.gz: 54ec75f07ceb38f0b0c6c96d457c071126741766
5
5
  SHA512:
6
- metadata.gz: 9abbb8ef8bbcda135f2a6e24972ef549ca561bd55f04fd007ae8e74cbc48165f91837619a74978c4791bb53586f41a6800dca1be48b3722ae8f61433399d1c1f
7
- data.tar.gz: 546f7f84e5075163bcaf1c531e1f0efd3e01146fb9d338adeebc39d30d30766dfb4b1228fa3d31361daee462431cb15d164b191251658aaa791f567f17af1506
6
+ metadata.gz: a216c7a57b097db0656994f03bd358cd155531b4c8f77168ea467abb1916ad93658a6d300b577a7f2de2050dfaec89751afa220d1ab16d3090e03e3cecf5fe42
7
+ data.tar.gz: 68bbd28e99288614fce22ad8007070940c4e2923937db2272400e0cb81c8e083f2c080f7265e6541c291c7a1a1ed25e07774786b7c701f95df5a142c415a3a8e
data/lib/scope.rb CHANGED
@@ -9,5 +9,6 @@ class Scope
9
9
  def initialize value
10
10
  fail "Invalid Scope (#{value})" unless Scope.valid? value
11
11
  @value = value
12
+ @short_value = get_short_value
12
13
  end
13
14
  end
data/lib/scope_methods.rb CHANGED
@@ -21,6 +21,8 @@ module ScopeMethods
21
21
  valid_month?(month(scope)) and valid_year?(year(scope))
22
22
  end
23
23
 
24
+
25
+
24
26
  def year scope
25
27
  scope[0..3].to_i
26
28
  end
@@ -64,6 +66,10 @@ module ScopeMethods
64
66
  Scope.month @value
65
67
  end
66
68
 
69
+ def month_to_s
70
+ month < 10 ? "0#{month.to_i}" : "#{month.to_i}"
71
+ end
72
+
67
73
  def prior
68
74
  date = Scope.scope_to_date(@value).prev_month
69
75
  Scope.date_to_scope date
@@ -85,6 +91,11 @@ module ScopeMethods
85
91
  def <=>(other)
86
92
  to_date <=> other.to_date
87
93
  end
94
+
95
+ private
96
+ def get_short_value
97
+ "#{year - 2000}#{month_to_s}"
98
+ end
88
99
  end
89
100
 
90
101
  def self.included receiver
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scoppie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gedean Dias
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-22 00:00:00.000000000 Z
11
+ date: 2016-10-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Scope handler
14
14
  email: gedean.dias@gmail.com