cotacao 0.0.4 → 0.1.4

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
  SHA1:
3
- metadata.gz: c9e1c898f013f762a1c66ee72235314393e39612
4
- data.tar.gz: db776ecf3b9f6043416b87d6c142f0331c60d959
3
+ metadata.gz: bb412e08262a1a0365d756a84845f61d7e0261f6
4
+ data.tar.gz: 2e441c416173e95df3ecc5ba3bc89dab057680f6
5
5
  SHA512:
6
- metadata.gz: db0989d26e55657dad50e1f44f8f45d4fe5a845a39f41a9c953f0b381e594cfcaab6443cad4161668e2c4efd19b98e44d1d353263a8c3f55f79c883b8dd19c61
7
- data.tar.gz: 496f68ea133f53928f3ed2f6ea2b29d9ec699247ac2dfe9de1635f7c6dbe6da2cc5bee24377c8b65af6c2596542f69a4722e738efa2c3abefe3414dce18534c7
6
+ metadata.gz: f0532208d88e9626cb25834bcc735f3baddca4af9935145b38a0efb3c07839889e45e13a5517554313836449aa352783d3d006bd020b3d6650568611afe6c6dd
7
+ data.tar.gz: 5ec18c50bd7bb7770c8395db98f870586698e2b99306c8ae92f6fc95dedbe3e37879e5e03ab2d66ac16b566bb1ace4b700a2ee73b1422d80060d6a5ca2bd25fa
data/bin/cotacao CHANGED
@@ -4,4 +4,14 @@ require 'cotacao'
4
4
 
5
5
  cotacao = Cotacao::Cotacao.new
6
6
 
7
- puts cotacao.now
7
+ if ARGV.empty?
8
+ puts cotacao.now
9
+ end
10
+
11
+ if ARGV[0] == 'dolar'
12
+ unless ARGV[1]
13
+ puts cotacao.dolar
14
+ else
15
+ puts cotacao.dolar(ARGV[1])
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Cotacao
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/cotacao.rb CHANGED
@@ -13,11 +13,24 @@ module Cotacao
13
13
  end
14
14
 
15
15
  def now
16
- self.console_print('dolar', @data['dolar'], "Dolar: R$ #{@data['dolar']['cotacao']} - Variação: #{@data['dolar']['variacao']}")
16
+ self.dolar(nil)
17
17
  self.console_print('euro', @data['euro'], "Euro: R$ #{@data['euro']['cotacao']} - Variação: #{@data['euro']['variacao']}")
18
18
  self.console_print('bovespa', @data['bovespa'], "Bovespa: #{@data['bovespa']['cotacao']} - Variação: #{@data['bovespa']['variacao']}")
19
19
  end
20
20
 
21
+ def dolar(convert_to)
22
+ dolar = @data['dolar']
23
+ cotacao = dolar['cotacao']
24
+ variacao = dolar['variacao']
25
+ convertion_string = ''
26
+
27
+ if convert_to
28
+ convertion_string = "- Em Reais: R$ #{self.convert(cotacao, convert_to)}"
29
+ end
30
+
31
+ self.console_print('dolar', dolar, "Dolar: R$ #{cotacao} - Variação: #{variacao} #{convertion_string}")
32
+ end
33
+
21
34
  def console_print(type, cotacao, copy)
22
35
  puts '----------------------'
23
36
  puts paint(copy, cotacao['variacao'].to_f)
@@ -44,5 +57,9 @@ module Cotacao
44
57
  end
45
58
  end
46
59
 
60
+ def convert(foreign_currency, real)
61
+ '%.2f' % (real.to_f * foreign_currency.to_f)
62
+ end
63
+
47
64
  end
48
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cotacao
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thadeu Brito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-20 00:00:00.000000000 Z
11
+ date: 2015-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler