Class: Forex::Trader

Inherits:
Object
  • Object
show all
Defined in:
lib/forex/trader.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(short_name) ⇒ Trader

Returns a new instance of Trader.



29
30
31
# File 'lib/forex/trader.rb', line 29

def initialize(short_name)
  @short_name = short_name
end

Class Attribute Details

.allObject

Returns the value of attribute all.



14
15
16
# File 'lib/forex/trader.rb', line 14

def all
  @all
end

Instance Attribute Details

#base_currencyObject

Returns the value of attribute base_currency.



5
6
7
# File 'lib/forex/trader.rb', line 5

def base_currency
  @base_currency
end

#endpointObject

Returns the value of attribute endpoint.



5
6
7
# File 'lib/forex/trader.rb', line 5

def endpoint
  @endpoint
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/forex/trader.rb', line 5

def name
  @name
end

#ratesObject

Returns the value of attribute rates.



5
6
7
# File 'lib/forex/trader.rb', line 5

def rates
  @rates
end

#rates_parserObject

Returns the value of attribute rates_parser.



5
6
7
# File 'lib/forex/trader.rb', line 5

def rates_parser
  @rates_parser
end

#short_nameObject

Returns the value of attribute short_name.



5
6
7
# File 'lib/forex/trader.rb', line 5

def short_name
  @short_name
end

#twitter_handleObject

Returns the value of attribute twitter_handle.



5
6
7
# File 'lib/forex/trader.rb', line 5

def twitter_handle
  @twitter_handle
end

Class Method Details

.define(short_name) {|t| ... } ⇒ Object

Yields:

  • (t)

Raises:



16
17
18
19
20
21
22
# File 'lib/forex/trader.rb', line 16

def define(short_name)
  raise CannotRedefineTrader, short_name if all[short_name]

  t = Forex::Trader.new(short_name)
  yield t if block_given?
  @all[short_name] = t
end

.resetObject



24
25
26
# File 'lib/forex/trader.rb', line 24

def reset
  @all = Hash.new
end

Instance Method Details

#fetchObject



33
34
35
# File 'lib/forex/trader.rb', line 33

def fetch
  @rates = rates_parser.(doc)
end