class Trader::SyncConverter
Attributes
ttl[R]
Public Class Methods
new(_ttl, &_block)
click to toggle source
Calls superclass method
Trader::FixedConverter::new
# File lib/trade-o-matic/converters/sync_converter.rb, line 5 def initialize(_ttl, &_block) super nil @ttl = _ttl @block = _block end
Public Instance Methods
expired?()
click to toggle source
# File lib/trade-o-matic/converters/sync_converter.rb, line 11 def expired? @rate.nil? || @last_sync < (Time.now - @ttl) end
rate()
click to toggle source
# File lib/trade-o-matic/converters/sync_converter.rb, line 15 def rate if expired? @rate = @block.call @last_sync = Time.now end @rate end