Class: XRBP::Model::Market

Inherits:
Base
  • Object
show all
Extended by:
Base::ClassMethods
Defined in:
lib/xrbp/model/market.rb

Instance Attribute Summary collapse

Attributes included from Base::ClassMethods

#connection, #opts

Attributes inherited from Base

#connection, #opts

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#full_opts

Constructor Details

#initialize(opts = {}) ⇒ Market

Returns a new instance of Market.


27
28
29
# File 'lib/xrbp/model/market.rb', line 27

def initialize(opts={})
  set_opts(opts)
end

Instance Attribute Details

#routeObject

Returns the value of attribute route


25
26
27
# File 'lib/xrbp/model/market.rb', line 25

def route
  @route
end

Class Method Details

.all(opts = {}) ⇒ Object

Retrieve list of markets via WebClient::Connection

Parameters:

  • opts (Hash) (defaults to: {})

    options to retrieve market list with

Options Hash (opts):


15
16
17
18
19
20
21
22
23
# File 'lib/xrbp/model/market.rb', line 15

def self.all(opts={})
  set_opts(opts)
  connection.url = "https://api.cryptowat.ch/assets/xrp"

  connection.add_plugin :result_parser  unless connection.plugin?(:result_parser)
  connection.add_plugin Parsers::Market unless connection.plugin?(Parsers::Market)

  connection.perform
end

Instance Method Details

#quotes(opts = {}) ⇒ Object

Retrieve list of quotes for market via WebClient::Connection

Parameters:

  • opts (Hash) (defaults to: {})

    options to retrieve quotes with

Options Hash (opts):


41
42
43
44
45
46
47
48
49
# File 'lib/xrbp/model/market.rb', line 41

def quotes(opts={})
  set_opts(opts)
  connection.url = self.route

  connection.add_plugin :result_parser unless connection.plugin?(:result_parser)
  connection.add_plugin Parsers::Quote unless connection.plugin?(Parsers::Quote)

  connection.perform
end

#set_opts(opts = {}) ⇒ Object


31
32
33
34
# File 'lib/xrbp/model/market.rb', line 31

def set_opts(opts={})
  super opts
  @route = opts[:route] if opts[:route]
end