module Nis::Util
Constants
- MAINNET
- MAINNET_VERSION_1
- MAINNET_VERSION_2
- MIJIN
- NEM_EPOCH
- TESTNET
- TESTNET_VERSION_1
- TESTNET_VERSION_2
- VERSION_1
- VERSION_2
Public Class Methods
deadline(seconds = 3600)
click to toggle source
# File lib/nis/util.rb, line 33 def self.deadline(seconds = 3600) timestamp + seconds end
error_handling(hash)
click to toggle source
# File lib/nis/util.rb, line 41 def self.error_handling(hash) error_klass = case hash[:error] when 'Not Found' then Nis::NotFoundError when 'Bad Request' then Nis::BadRequestError when 'Internal Server Error' then Nis::InternalServerError else Nis::Error end error_klass.new(hash[:message]) end
parse_nemtime(nemtime)
click to toggle source
# File lib/nis/util.rb, line 29 def self.parse_nemtime(nemtime) NEM_EPOCH + nemtime end
parse_network(network)
click to toggle source
# File lib/nis/util.rb, line 20 def self.parse_network(network) case network when :mijin then MIJIN when :mainnet then MAINNET when :testnet then TESTNET else TESTNET end end
parse_version(network, version)
click to toggle source
# File lib/nis/util.rb, line 16 def self.parse_version(network, version) parse_network(network) | version end
timestamp()
click to toggle source
# File lib/nis/util.rb, line 37 def self.timestamp (Time.now.utc - NEM_EPOCH).to_i end