trades 1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/trades +6 -6
  2. data/lib/trades/trade.rb +1 -5
  3. metadata +7 -7
data/bin/trades CHANGED
@@ -33,14 +33,14 @@ begin
33
33
  end
34
34
 
35
35
  # Compare price of this trade with last trade
36
- unless last_price[trade.market].nil?
37
- price = trade.price # we need to save an uncolored copy later
38
- trade.price.green if price > last_price[trade.market]
39
- trade.price.red if price < last_price[trade.market]
40
- last_price[trade.market] = price
36
+ if last_price.key? trade.market
37
+ color = 'green' if trade.price > last_price[trade.market]
38
+ color = 'red' if trade.price < last_price[trade.market]
41
39
  end
40
+
41
+ last_price[trade.market] = trade.price
42
42
 
43
- puts trade
43
+ puts color.nil? ? trade : trade.to_s.send(color)
44
44
  options.logger.info trade if options.log
45
45
  end
46
46
  rescue Interrupt
data/lib/trades/trade.rb CHANGED
@@ -24,12 +24,8 @@ class Trade
24
24
  Time.at(@timestamp).strftime(format)
25
25
  end
26
26
 
27
- def price(decimals = 4)
28
- @price.round(decimals)
29
- end
30
-
31
27
  def to_s
32
28
  "#{@market.ljust(15)} | #{timestamp()} | #{@currency.ljust(9)} | " +
33
- "#{price().to_s.ljust(9)} | #{@volume.to_s}"
29
+ "#{@price.round(4).to_s.ljust(9)} | #{@volume.to_s}"
34
30
  end
35
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trades
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-16 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &2156540440 !ruby/object:Gem::Requirement
16
+ requirement: &2157809480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156540440
24
+ version_requirements: *2157809480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: colored
27
- requirement: &2156539960 !ruby/object:Gem::Requirement
27
+ requirement: &2157809000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.2'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2156539960
35
+ version_requirements: *2157809000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json
38
- requirement: &2156562520 !ruby/object:Gem::Requirement
38
+ requirement: &2157808540 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 1.6.1
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2156562520
46
+ version_requirements: *2157808540
47
47
  description: Displays the trading data that Bitcoincharts monitors nicely
48
48
  email:
49
49
  executables: