Module: Honeymaker::Utils

Defined in:
lib/honeymaker/utils.rb

Class Method Summary collapse

Class Method Details

.decimals(num) ⇒ Object



5
6
7
8
9
10
# File 'lib/honeymaker/utils.rb', line 5

def self.decimals(num)
  return 0 if num.nil?
  str = num.to_s.sub(/\.?0+$/, "")
  return 0 unless str.include?(".")
  str.split(".").last.length
end

.parse_filters(filters) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/honeymaker/utils.rb', line 12

def self.parse_filters(filters)
  {
    price: filters.find { |f| f["filterType"] == "PRICE_FILTER" },
    lot_size: filters.find { |f| f["filterType"] == "LOT_SIZE" },
    notional: filters.find { |f| %w[NOTIONAL MIN_NOTIONAL].include?(f["filterType"]) }
  }
end