Class: Trader::JsonApiConverter
- Inherits:
-
SyncConverter
- Object
- Converter
- FixedConverter
- SyncConverter
- Trader::JsonApiConverter
- Defined in:
- lib/trade-o-matic/converters/json_api_converter.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Attributes inherited from SyncConverter
Attributes inherited from FixedConverter
Instance Method Summary collapse
-
#initialize(_url, _path, _ttl = 30) ⇒ JsonApiConverter
constructor
A new instance of JsonApiConverter.
Methods inherited from SyncConverter
Methods inherited from FixedConverter
Methods inherited from Converter
Constructor Details
#initialize(_url, _path, _ttl = 30) ⇒ JsonApiConverter
Returns a new instance of JsonApiConverter.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/trade-o-matic/converters/json_api_converter.rb', line 8 def initialize(_url, _path, _ttl=30) @url = _url @path = _path super(_ttl) do json_string = RestClient.get _url json = JSON.parse json_string value = _path.inject(json) { |r, k| r[k] } Standard.amount value end end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/trade-o-matic/converters/json_api_converter.rb', line 6 def path @path end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/trade-o-matic/converters/json_api_converter.rb', line 6 def url @url end |