stocks 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stocks.rb +3 -1
- data/lib/stocks/quote.rb +4 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff8f8f4c0267e7654a38c3cc511135844ffc6914
|
4
|
+
data.tar.gz: e3cbcfa491f9c431ddb17c68d3b4604c9401206e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 045675fb009239335d5fe8121a8aef430ccddd0d29957dfe80decf7ead3beb700c20f43f428a16cf822080e23d4b2d76424f86c5861f2aeff2a13531638fb544
|
7
|
+
data.tar.gz: 08dee3b68151772e86a321aa9f4c91b5d042f48b4e73b23b3f791b55ac6eb279bc3122107a9373955abf8fd305561693ca1bcd890fa190a9714fe4f405705333
|
data/lib/stocks.rb
CHANGED
@@ -13,6 +13,8 @@ require 'stocks/validators/exists'
|
|
13
13
|
|
14
14
|
# Provides an interface to do real-time analysis of stocks.
|
15
15
|
module Stocks
|
16
|
+
NOT_AVAILABLE = 'N/A' # :nodoc:
|
17
|
+
|
16
18
|
# Determines whether or not the provided symbol exists.
|
17
19
|
#
|
18
20
|
# ===== *Args*
|
@@ -21,7 +23,7 @@ module Stocks
|
|
21
23
|
# Whether or not the provided symbol exists
|
22
24
|
def self.exists?(symbol)
|
23
25
|
symbol.upcase!
|
24
|
-
EXISTS_CACHE.fetch(symbol) { !
|
26
|
+
EXISTS_CACHE.fetch(symbol) { !Quote.get(symbol)[symbol][:date].nil? }
|
25
27
|
end
|
26
28
|
|
27
29
|
# Raises an exception if the provided symbol does not exist.
|
data/lib/stocks/quote.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# License:: MIT
|
3
3
|
|
4
4
|
module Stocks
|
5
|
-
# Reprsents an instance of a stock quote.
|
5
|
+
# Reprsents an instance of a stock quote.
|
6
6
|
class Quote < Hash
|
7
7
|
# Mapping from base_quote type to YahooFinance method of retrieval
|
8
8
|
# (options: :extended, :standard)
|
@@ -28,6 +28,7 @@ module Stocks
|
|
28
28
|
|
29
29
|
quotes = YahooFinance.send(Quote::TYPES[type], symbols)
|
30
30
|
quotes.each_pair { |symbol, quote| quotes[symbol] = Quote.new(quote) }
|
31
|
+
|
31
32
|
quotes
|
32
33
|
end
|
33
34
|
|
@@ -37,18 +38,16 @@ module Stocks
|
|
37
38
|
get_fields.each { |field| self[field] = base_quote.send(field) } if valid?
|
38
39
|
end
|
39
40
|
|
40
|
-
# Determines whether or not the quote is valid.
|
41
|
+
# Determines whether or not the quote is valid.
|
41
42
|
#
|
42
43
|
# ===== *Returns*
|
43
|
-
# Whether or not the quote is valid
|
44
|
+
# Whether or not the quote is valid
|
44
45
|
def valid?
|
45
46
|
@base_quote.name != NOT_AVAILABLE
|
46
47
|
end
|
47
48
|
|
48
49
|
private
|
49
50
|
|
50
|
-
NOT_AVAILABLE = 'N/A' # :nodoc:
|
51
|
-
|
52
51
|
attr_accessor :base_quote
|
53
52
|
|
54
53
|
# :nodoc:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Fornaciari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|