Sha256: 24305359edb46446205a1e24ab96d6088987e923351e58958f0d93b0e2e76f56

Contents?: true

Size: 518 Bytes

Versions: 57

Compression:

Stored size: 518 Bytes

Contents

module Paypal
  module Util

    def self.formatted_amount(x)
      # Thanks @nahi ;)
      sprintf "%0.2f", BigDecimal.new(x.to_s).truncate(2)
    end

    def self.to_numeric(x)
      if x.to_f == x.to_i
        x.to_i
      else
        x.to_f
      end
    end

    def numeric_attribute?(key)
      !!(key.to_s =~ /(amount|frequency|cycles|paid)/)
    end

    def ==(other)
      instance_variables.all? do |key|
        instance_variable_get(key) == other.instance_variable_get(key)
      end
    end

  end
end

Version data entries

57 entries across 57 versions & 3 rubygems

Version Path
creative-paypal-express-1.2.1 lib/paypal/util.rb
creative-paypal-express-1.2.0 lib/paypal/util.rb
creative-paypal-express-1.1.0 lib/paypal/util.rb
dfg-paypal-0.8.2 lib/paypal/util.rb
creative-paypal-express-1.0.1.dev2 lib/paypal/util.rb
creative-paypal-express-1.0.1.dev1 lib/paypal/util.rb
creative-paypal-express-1.0.0 lib/paypal/util.rb
creative-paypal-express-0.8.2.4 lib/paypal/util.rb
creative-paypal-express-0.8.2.3 lib/paypal/util.rb
creative-paypal-express-0.8.2.2 lib/paypal/util.rb
creative-paypal-express-0.8.2.1 lib/paypal/util.rb
creative-paypal-express-0.8.2 lib/paypal/util.rb
creative-paypal-express-0.8.1 lib/paypal/util.rb
paypal-express-0.8.1 lib/paypal/util.rb
paypal-express-0.8.0 lib/paypal/util.rb
paypal-express-0.7.1 lib/paypal/util.rb
paypal-express-0.7.0 lib/paypal/util.rb
paypal-express-0.6.0 lib/paypal/util.rb
paypal-express-0.5.5 lib/paypal/util.rb
paypal-express-0.5.4 lib/paypal/util.rb