Sha256: 51c89395e73017e87d0d11db21e1ef7029acc6480c0a4546bfcc55143e12a72b

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 Bytes

Contents

module Polyfill
  module V2_4
    module Comparable
      module Clamp
        module Method
          def clamp(min, max)
            if min > max
              raise ArgumentError, 'min argument must be smaller than max argument'
            end

            return min if min > self
            return max if max < self
            self
          end if RUBY_VERSION < '2.4.0'
        end

        if RUBY_VERSION < '2.4.0'
          refine ::Numeric do
            include Method
          end
          refine ::String do
            include Method
          end
          refine ::Time do
            include Method
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polyfill-0.2.0 lib/polyfill/v2_4/comparable/clamp.rb