class CryptoconditionsRuby::Types::TimeoutFulfillment

Constants

FEATURE_BITMASK
REGEX
TYPE_ID

Public Class Methods

new(expire_time = nil) click to toggle source
# File lib/cryptoconditions_ruby/types/timeout_fulfillment.rb, line 14
def initialize(expire_time = nil)
  if expire_time.is_a?(String) && !expire_time.match(REGEX)
    raise TypeError, "Expire time must be conform UTC unix time, was: #{expire_time}"
  end
  super if expire_time
end
timestamp(time) click to toggle source
# File lib/cryptoconditions_ruby/types/timeout_fulfillment.rb, line 10
def self.timestamp(time)
  format('%6f', time.to_f)
end

Public Instance Methods

expire_time() click to toggle source
# File lib/cryptoconditions_ruby/types/timeout_fulfillment.rb, line 21
def expire_time
  preimage
end
parse_dict(data) click to toggle source
# File lib/cryptoconditions_ruby/types/timeout_fulfillment.rb, line 34
def parse_dict(data)
  self.preimage = data['expire_time']
end
to_dict() click to toggle source
# File lib/cryptoconditions_ruby/types/timeout_fulfillment.rb, line 25
def to_dict
  {
    'type' => 'fulfillment',
    'type_id' => TYPE_ID,
    'bitmask' => bitmask,
    'expire_time' => expire_time
  }
end
validate(message: nil, now: nil, **_kwargs) click to toggle source
# File lib/cryptoconditions_ruby/types/timeout_fulfillment.rb, line 38
def validate(message: nil, now: nil, **_kwargs)
  unless now || now.match(REGEX)
    raise TypeError, "message must be of unix time format, was: #{message}"
  end
  now.to_f <= expire_time.to_f
end