stocks 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stocks/quote.rb +21 -19
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 911fce4a35b7e344b06251c4ea2fc44ca0c9e817
|
4
|
+
data.tar.gz: 26f40e4ef0111cff2adcdf6093db36984e1e6d13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 032e3ff200dea1284fe9b1bed083185ed04cb12f591f42a6cde96404270e2b5006a8216c8b17dd6075a89c596db2282788fbc4ae971688592380d266e035fbc1
|
7
|
+
data.tar.gz: efaf177ee08f5ee4ad964264e5be6f21e9de71ea945f91a1c35162b7f46bdfb6d80b84cb86c1a41c668202440eb502e40e69fcf88694ac790517a43293a8365b
|
data/lib/stocks/quote.rb
CHANGED
@@ -2,29 +2,31 @@
|
|
2
2
|
# License:: MIT
|
3
3
|
|
4
4
|
# Provides an instance of a stock quote.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
module Stocks
|
6
|
+
class Quote < Hash
|
7
|
+
# Mapping from base_quote type to YahooFinance method of retrieval
|
8
|
+
TYPES = {
|
9
|
+
'extended': :get_extended_quotes,
|
10
|
+
'standard': :get_standard_quotes
|
11
|
+
}
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def initialize(base_quote)
|
14
|
+
@base_quote = base_quote
|
15
|
+
get_fields.each { |field| self[field] = base_quote.send(field) }
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
+
private
|
18
19
|
|
19
|
-
|
20
|
+
attr_accessor :base_quote
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
# :nodoc:
|
23
|
+
def get_fields
|
24
|
+
@base_quote.instance_variables.map { |f|
|
25
|
+
f.to_s.gsub('@','').to_sym
|
26
|
+
}.reject { |f_sym|
|
27
|
+
!@base_quote.public_methods.include?(f_sym)
|
28
|
+
}
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|