Sha256: f484d73eeb665674d469f3004ba959c0887fb2264b27daafd911b095b5b507ce

Contents?: true

Size: 739 Bytes

Versions: 5

Compression:

Stored size: 739 Bytes

Contents

##
# Extensions to Numeric.
class Numeric

  ##
  # @return [Numeric] the value clamped between a minimum and maximum value.
  # @param min [Numeric] The minimum permitted value.
  # @param max [Numeric] The maximum permitted value.
  def clamp(min, max)
    [min, self, max].sort[1]
  end
end

##
# Extensions to String.
class String

  # Not defined until Ruby 2.4.0
  unless method_defined?(:unpack1)
    def unpack1(format)
      unpack(format).first
    end
  end
end

##
# Extensions to TrueClass.
class TrueClass

  ##
  # @return [Integer] the object as an Integer (1).
  def to_i
    1
  end
end

##
# Extensions to FalseClass.
class FalseClass

  ##
  # @return [Integer] the object as an Integer (0).
  def to_i
    0
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fmod-0.9.6 lib/fmod/core/extensions.rb
fmod-0.9.5 lib/fmod/core/extensions.rb
fmod-0.9.4 lib/fmod/core/extensions.rb
fmod-0.9.3 lib/fmod/core/extensions.rb
fmod-0.9.2 lib/fmod/core/extensions.rb