Class: Economy::Rates::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/economy/rates/base.rb

Direct Known Subclasses

Yahoo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



7
8
9
# File 'lib/economy/rates/base.rb', line 7

def initialize
  @retries = 0
end

Instance Attribute Details

#retriesObject (readonly)

Returns the value of attribute retries.



5
6
7
# File 'lib/economy/rates/base.rb', line 5

def retries
  @retries
end

Instance Method Details

#fetchObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/economy/rates/base.rb', line 11

def fetch
  begin
    call
  rescue
    if retries < 30
      sleep 60
      @retries += 1
      fetch
    else
      puts "Giving up after #{retries} retries"
    end
  end
end