Sha256: 544b0985157fd0cc94493c6f98d3e61969fcbd780b6d8f290f2e728ca6973e2b

Contents?: true

Size: 328 Bytes

Versions: 24

Compression:

Stored size: 328 Bytes

Contents

require 'active_support/inflector/methods'

class Numeric
  Weighable::Weight::UNIT.each do |unit, _|
    unit = unit.to_s
    plural_unit = ActiveSupport::Inflector.pluralize(unit)
    define_method unit do
      Weighable::Weight.new(self, unit)
    end
    alias_method plural_unit, unit unless plural_unit == unit
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
weighable-1.5.0 lib/weighable/core_ext/numeric.rb
weighable-1.4.0 lib/weighable/core_ext/numeric.rb
weighable-1.3.0 lib/weighable/core_ext/numeric.rb
weighable-1.2.1 lib/weighable/core_ext/numeric.rb
weighable-1.2.0 lib/weighable/core_ext/numeric.rb
weighable-1.1.0 lib/weighable/core_ext/numeric.rb
weighable-1.0.1 lib/weighable/core_ext/numeric.rb
weighable-1.0.0 lib/weighable/core_ext/numeric.rb
weighable-0.10.1 lib/weighable/core_ext/numeric.rb
weighable-0.10.0 lib/weighable/core_ext/numeric.rb
weighable-0.9.0 lib/weighable/core_ext/numeric.rb
weighable-0.8.1 lib/weighable/core_ext/numeric.rb
weighable-0.8.0 lib/weighable/core_ext/numeric.rb
weighable-0.7.1 lib/weighable/core_ext/numeric.rb
weighable-0.7.0 lib/weighable/core_ext/numeric.rb
weighable-0.6.1 lib/weighable/core_ext/numeric.rb
weighable-0.6.0 lib/weighable/core_ext/numeric.rb
weighable-0.5.1 lib/weighable/core_ext/numeric.rb
weighable-0.5.0 lib/weighable/core_ext/numeric.rb
weighable-0.4.0 lib/weighable/core_ext/numeric.rb