horario 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/horario +43 -29
  2. metadata +2 -2
data/bin/horario CHANGED
@@ -1,45 +1,59 @@
1
1
  #!/usr/bin/env ruby
2
+ # encoding: utf-8
2
3
 
3
4
  require 'colorize'
4
5
 
5
- # first_number = ARGV[0].to_i
6
- # second_number = ARGV[1].to_i
7
-
8
- puts
9
- puts
10
- print ' Digite a hora de entrada: '.green
11
- hour = gets.chomp
12
-
13
- puts
14
- print ' Digite os minutos de entrada: '.green
15
- minutes = gets.chomp
16
-
17
- puts
18
- print ' Digite as horas adicionais: '.green
19
- hours_add = gets.chomp
20
-
21
- puts
22
- print ' Digite os minutos adicionais: '.green
23
- minutes_add = gets.chomp
6
+ if (ARGV.size == 0)
7
+ puts
8
+ print ' Horario diário (h:m): '.green
9
+ total = gets.chomp
10
+
11
+ puts
12
+ print ' Hora de entrada (h:m): '.green
13
+ hour = gets.chomp
14
+
15
+ puts
16
+ print ' Tempo adicional (h:m): '.green
17
+ hour_add = gets.chomp
18
+ elsif (ARGV.size == 2)
19
+ total = ARGV[0]
20
+ hour = ARGV[1]
21
+ elsif (ARGV.size == 3)
22
+ total = ARGV[0]
23
+ hour = ARGV[1]
24
+ hour_add = ARGV[2]
25
+ end
26
+
27
+ total = total.split(':') if total
28
+ hour = hour.split(':') if hour
29
+ hour_add = hour_add.split(':') if hour_add
24
30
 
25
31
  now = Time.now
26
32
  year = now.year
27
33
  month = now.month
28
34
  day = now.day
29
- hour = Integer(hour)
30
- minutes = Integer(minutes)
31
- hours_add = Integer(hours_add)
32
- hours_add = (60 * 60 * hours_add)
33
- minutes_add = Integer(minutes_add)
34
- minutes_add = (60 * 60 * (100/60.0*minutes_add/100))
35
-
35
+ minutes = Integer(hour[1])
36
+ hour = Integer(hour[0])
37
+
38
+ if (hour_add)
39
+ minutes_add = Integer(hour_add[1])
40
+ hour_add = Integer(hour_add[0])
41
+
42
+ hour_add = (60 * 60 * hour_add)
43
+ minutes_add = (60 * 60 * (100/60.0*minutes_add/100))
44
+ else
45
+ hour_add = 0
46
+ minutes_add = 0
47
+ end
48
+
49
+ total_hours = Integer(total[0])
50
+ total_minutes = Integer(total[1])
36
51
 
37
52
  time = Time.new(year, month, day, hour, minutes, 0)
38
- interval = (60 * 60 * (9 + (100/60.0*48/100)))
39
- result = (time+interval+hours_add+minutes_add).strftime('%H:%M')
53
+ interval = (60 * 60 * (total_hours + (100/60.0*total_minutes/100)))
54
+ result = (time+interval+hour_add+minutes_add).strftime('%H:%M')
40
55
 
41
56
  puts
42
57
  puts " Seu horario de saida e #{result}".yellow
43
58
  puts
44
- puts
45
59
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: horario
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-10 00:00:00.000000000 Z
12
+ date: 2012-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize