Sha256: 40e375cb3634903c5bc2f875f2b5bdc4c925986b37b278d05383b5d7089ae36a
Contents?: true
Size: 752 Bytes
Versions: 62
Compression:
Stored size: 752 Bytes
Contents
module Workarea class CleanRangeFacets def initialize(raw) @raw = raw.to_h end def result cleaned_ranges = @raw.inject({}) do |result, (name, ranges)| result[name] = clean_ranges(ranges) result end cleaned_ranges.reject { |n, f| n.blank? || f.blank? } end private def clean_ranges(ranges) ranges .map do |range| if range['to'].present? range['to'] = range['to'].to_f else range.delete('to') end if range['from'].present? range['from'] = range['from'].to_f else range.delete('from') end range end .reject(&:blank?) end end end
Version data entries
62 entries across 62 versions & 1 rubygems