module Express::Util

Public Class Methods

formatted_amount(x) click to toggle source
# File lib/express/util.rb, line 3
def self.formatted_amount(x)
  # Thanks @nahi ;)
  sprintf "%0.2f", BigDecimal.new(x.to_s).truncate(2)
end
to_numeric(x) click to toggle source
# File lib/express/util.rb, line 8
def self.to_numeric(x)
  if x.to_f == x.to_i
    x.to_i
  else
    x.to_f
  end
end

Public Instance Methods

==(other) click to toggle source
# File lib/express/util.rb, line 20
def ==(other)
  instance_variables.all? do |key|
    instance_variable_get(key) == other.instance_variable_get(key)
  end
end
numeric_attribute?(key) click to toggle source
# File lib/express/util.rb, line 16
def numeric_attribute?(key)
  !!(key.to_s =~ /(amount|frequency|cycles|paid)/)
end