class ItBitSDK::Services::Bitcoin::Withdrawal::Request::CheckSchedule

Public Class Methods

new() click to toggle source
# File lib/it_bit_sdk/services/bitcoin/withdrawal/request/check_schedule.rb, line 7
def initialize
  @time_ranges = [
    { start: datetime_for('Singapore', 9),  end: datetime_for('Singapore', 10) },
    { start: datetime_for('Singapore', 12), end: datetime_for('Singapore', 13) },
    { start: datetime_for('Singapore', 15), end: datetime_for('Singapore', 15, 30) },
    { start: datetime_for('Singapore', 22), end: datetime_for('Singapore', 23) },
    { start: datetime_for('Singapore', 1), end: datetime_for('Singapore', 2) },
    { start: datetime_for('Singapore', 4), end: datetime_for('Singapore', 5) },
    { start: datetime_for('Eastern Time (US & Canada)', 9),  end: datetime_for('Eastern Time (US & Canada)', 10) },
    { start: datetime_for('Eastern Time (US & Canada)', 12), end: datetime_for('Eastern Time (US & Canada)', 13) },
    { start: datetime_for('Eastern Time (US & Canada)', 15), end: datetime_for('Eastern Time (US & Canada)', 15, 30) },
    { start: datetime_for('Eastern Time (US & Canada)', 20), end: datetime_for('Eastern Time (US & Canada)', 21) },
    { start: datetime_for('Eastern Time (US & Canada)', 0), end: datetime_for('Eastern Time (US & Canada)', 1) },
    { start: datetime_for('Eastern Time (US & Canada)', 2), end: datetime_for('Eastern Time (US & Canada)', 3) }
  ]
end

Public Instance Methods

call() click to toggle source
# File lib/it_bit_sdk/services/bitcoin/withdrawal/request/check_schedule.rb, line 24
def call
  @time_ranges.each do |range|
    return range if (range[:start]..range[:end]).cover?(Time.now.utc)
  end

  nil
end

Private Instance Methods

datetime_for(timezone, hours, minutes = 0) click to toggle source
# File lib/it_bit_sdk/services/bitcoin/withdrawal/request/check_schedule.rb, line 34
def datetime_for(timezone, hours, minutes = 0)
  Time.now.in_time_zone(timezone).change({ hour: hours, min: minutes }).utc
end