sinatra-hexacta 0.9.12 → 1.0.0

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
  SHA256:
3
- metadata.gz: cc4e539f65371ebb4d52b73e185f6d41bf0576d568ca371150b6bbe9e4d0c49c
4
- data.tar.gz: 841dc6b738b38f5afcdbf7b73dc23c9d57a7d7111d890c6f7457ee7fb8cfb82b
3
+ metadata.gz: 235207ce86479d51ab5c1852a286ab92d5b4de8fbd159d584bc79234bcafd5dc
4
+ data.tar.gz: 933097a5eca58c05479cb29e93543c9e9ca292eb45c61b940be4ab9c4cf80f9c
5
5
  SHA512:
6
- metadata.gz: 2240105d063c417614628c4ae4da5e9e4271d4d9e290d1aafba2421c9c7fff265bc5b519f99ff6281fb193755f166ae85ee657c23167ddf68f856c0ac83fe5cc
7
- data.tar.gz: 643d0ac518473058ba06466037125019ff852fe03cfaf71b0b9cd1700c224fee5e80b77cc9df42a564c6d5d4102c87d33456e64a91881d947b3c6b3a5c21fa9e
6
+ metadata.gz: c57ec64f35c7f71a043278ffc15e8e131f53cc8a29dfcb353475baa4763a27b09e323eacb16c0f652b209eb44d22383f8e91096403e42e35cfd73f08c5ec10ef
7
+ data.tar.gz: 2bfb5b976a50e30124bce1b534953b68e4c95f7398b4d34dace6afee55204b32adaec6bf67ac892f2cd33554a048a4f98be171a0ad17ac72581ef19aa32b8e5e
@@ -5,16 +5,16 @@ class Antiquity
5
5
  @periods = periods.sort { |a,b| a.start_date <=> b.start_date }
6
6
  end
7
7
 
8
- def days
9
- @periods.inject(0) { |total, period| total + period.days }
8
+ def days(upto_date=Date.today)
9
+ @periods.inject(0) { |total, period| total + period.days(upto_date) }
10
10
  end
11
11
 
12
- def months
13
- @periods.inject(0) { |total, period| total + period.months }
12
+ def months(upto_date=Date.today)
13
+ @periods.inject(0) { |total, period| total + period.months(upto_date) }
14
14
  end
15
15
 
16
- def years
17
- months.divmod(12).first
16
+ def years(upto_date=Date.today)
17
+ months(upto_date).divmod(12).first
18
18
  end
19
19
 
20
20
  def to_s(upto_date=Date.today)
@@ -22,11 +22,13 @@ class Antiquity
22
22
  result = ""
23
23
  return result if @periods.empty?
24
24
  if date >= @periods.first.start_date
25
- result += years > 1 ? "#{years} años" : "#{years} año" unless years == 0
26
- result += ", " if years >= 1 && !(months.modulo(12).eql?(0))
27
- result += months.modulo(12) > 1 ? "#{months.modulo(12)} meses" : "#{months.modulo(12)} mes" unless months.modulo(12) == 0
28
- result += "#{(date - @periods.last.start_date).to_i} dias" if months.modulo(12) == 0 && years == 0 && date > @periods.last.start_date
29
- result += "Hoy!" if months.modulo(12) == 0 && date == @periods.last.start_date
25
+ years_upto_date = years(date)
26
+ months_upto_date = months(date)
27
+ result += years_upto_date > 1 ? "#{years_upto_date} años" : "#{years_upto_date} año" unless years_upto_date == 0
28
+ result += ", " if years_upto_date >= 1 && !(months_upto_date.modulo(12).eql?(0))
29
+ result += months_upto_date.modulo(12) > 1 ? "#{months_upto_date.modulo(12)} meses" : "#{months_upto_date.modulo(12)} mes" unless months_upto_date.modulo(12) == 0
30
+ result += "#{(date - @periods.last.start_date).to_i} dias" if months_upto_date.modulo(12) == 0 && years_upto_date == 0 && date > @periods.last.start_date
31
+ result += "Hoy!" if months_upto_date.modulo(12) == 0 && date == @periods.last.start_date
30
32
  end
31
33
  result += "En unos días..." if date < @periods.first.start_date
32
34
  result
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-hexacta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.12
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Zanger
@@ -163,7 +163,6 @@ files:
163
163
  - lib/sinatra/public/vendors/malihu-custom-scrollbar-plugin/mCSB_buttons.png
164
164
  - lib/sinatra/public/vendors/material-design-iconic-font/css/material-design-iconic-font.css
165
165
  - lib/sinatra/public/vendors/material-design-iconic-font/css/material-design-iconic-font.min.css
166
- - lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.eot
167
166
  - lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.svg
168
167
  - lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.ttf
169
168
  - lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.woff