Class: Mcoin::Market::Base
- Inherits:
-
Object
- Object
- Mcoin::Market::Base
show all
- Defined in:
- lib/mcoin/market/base.rb
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(type, currency) ⇒ Base
Returns a new instance of Base.
11
12
13
14
15
|
# File 'lib/mcoin/market/base.rb', line 11
def initialize(type, currency)
@type = type
@currency = currency
@retries = 0
end
|
Instance Method Details
#fetch ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/mcoin/market/base.rb', line 21
def fetch
@data ||= JSON.parse(Net::HTTP.get(uri))
self
rescue JSON::ParserError
return nil if @retries >= 3
@retries += 1
retry
end
|
#name ⇒ Object
17
18
19
|
# File 'lib/mcoin/market/base.rb', line 17
def name
self.class.name.split('::').last
end
|
#to_ticker ⇒ Object
30
31
32
|
# File 'lib/mcoin/market/base.rb', line 30
def to_ticker
raise NotImplementedError
end
|
#uri ⇒ Object
34
35
36
37
38
|
# File 'lib/mcoin/market/base.rb', line 34
def uri
options = { type: @type.upcase, currency: @currency.upcase }
uri = format(self.class.const_get(:ENDPOINT), options)
URI(uri)
end
|