Sha256: 53ef7b3ab7f9a9c349fb849881f05eed4c539765e656e0856e6016a231958129

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 Bytes

Contents

require 'transliterator'

module Buckaroo
  module Ideal
    module Util
      extend self
      
      def to_normalized_string(string)
        Transliterator.asciify(string.to_s)
      end
      
      def to_cents(amount)
        (amount.to_f * 100).round
      end
      
      def from_cents(cents)
        cents.to_f / 100
      end
      
      def to_numeric_boolean(boolean)
        boolean ? 1 : 0
      end
      
      def from_numeric_boolean(number)
        number.to_i == 1
      end
      
      def compact(subject)
        subject = subject.dup
        
        if subject.is_a?(Hash)
          subject.each do |key, value|
            subject.delete(key) unless value
          end
        end
        
        subject
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buckaroo-ideal-0.0.1 lib/buckaroo-ideal/util.rb