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.



31
32
33
# File 'lib/forex/trader.rb', line 31

def initialize(short_name)
  @short_name = short_name
end

Class Attribute Details

.allObject

Returns the value of attribute all.



16
17
18
# File 'lib/forex/trader.rb', line 16

def all
  @all
end

Instance Attribute Details

#base_currencyObject

Returns the value of attribute base_currency.



7
8
9
# File 'lib/forex/trader.rb', line 7

def base_currency
  @base_currency
end

#endpointObject

Returns the value of attribute endpoint.



7
8
9
# File 'lib/forex/trader.rb', line 7

def endpoint
  @endpoint
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/forex/trader.rb', line 7

def name
  @name
end

#ratesObject

Returns the value of attribute rates.



7
8
9
# File 'lib/forex/trader.rb', line 7

def rates
  @rates
end

#rates_parserObject

Returns the value of attribute rates_parser.



7
8
9
# File 'lib/forex/trader.rb', line 7

def rates_parser
  @rates_parser
end

#short_nameObject

Returns the value of attribute short_name.



7
8
9
# File 'lib/forex/trader.rb', line 7

def short_name
  @short_name
end

#twitter_handleObject

Returns the value of attribute twitter_handle.



7
8
9
# File 'lib/forex/trader.rb', line 7

def twitter_handle
  @twitter_handle
end

Class Method Details

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

Yields:

  • (t)

Raises:



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

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



26
27
28
# File 'lib/forex/trader.rb', line 26

def reset
  @all = Hash.new
end

Instance Method Details

#fetchObject



35
36
37
# File 'lib/forex/trader.rb', line 35

def fetch
  @rates = rates_parser.(doc)
end