Sha256: ecebaa4ec8d8936450b6f7509d64e4f109f7ed6b2fdd808d3f5fcdfe9e70d783

Contents?: true

Size: 1.24 KB

Versions: 7

Compression:

Stored size: 1.24 KB

Contents

class NilClass
  def val(*args)
    self
  end
end

class Time
  def formatted_datetime
    I18n.l(self, :format => "%d.%m.%Y %H:%M")
  end

  def formatted_date
    I18n.l(self, :format => "%d.%m.%Y")
  end
end

class TrueClass
  def to_i
    1
  end
end

class FalseClass
  def to_i
    0
  end
end

class Object
  def to_bool
    ![false, 'false', '0', 0, 'f', nil, ''].include?(self.respond_to?(:downcase) ? self.downcase : self)
  end
end

class Date
  def tomorrow?
    self.to_date == ::Date.tomorrow
  end
end

#module ActiveSupport
#  class OrderedHash < ::Hash
#    def to_yaml(opts = {})
#      YAML::quick_emit(self, opts) do |out|
#        out.map(nil, to_yaml_style) do |map|
#          each do |k, v|
#            map.add(k, v)
#          end
#        end
#      end
#    end
#  end
#end

#class Numeric
#  # round a given number to the nearest step
#  def round_by(increment)
#    (self /increment).round * increment
#  end
#end
#
#class Float
#  def ceil_to(i=4)
#    #(self * 10**i).ceil.to_f / 10**i
#    (self * (10.0 ** i)).round(10).ceil * (10.0 ** (-i))
#  end
#
#  def floor_to(i=4)
#    (self * 10**i).floor.to_f / 10**i
#  end
#
#  def round_to
#    return (self+0.5).floor if self > 0.0
#    return (self-0.5).ceil if self < 0.0
#    0
#  end
#end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ab_admin-0.2.3 lib/ab_admin/core_ext/other.rb
ab_admin-0.2.2 lib/ab_admin/core_ext/other.rb
ab_admin-0.2.1 lib/ab_admin/core_ext/other.rb
ab_admin-0.2.0 lib/ab_admin/core_ext/other.rb
ab_admin-0.1.2 lib/ab_admin/core_ext/other.rb
ab_admin-0.1.1 lib/ab_admin/core_ext/other.rb
ab_admin-0.1.0 lib/ab_admin/core_ext/other.rb