From 8f39c34d5496164c0f9425c28730915b054eea51 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Mon, 18 Jun 2018 11:47:44 -0500 Subject: [PATCH] Added monkey patch to support rubies < 2.5 --- Gemfile.lock | 10 +++------- i-mic-fps.rb | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7d269d2..e3308f8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,10 @@ GEM remote: https://rubygems.org/ specs: - chunky_png (1.3.10) - glu (8.2.2) - glu (8.2.2-x86-mingw32) + glu (8.3.0) + glu (8.3.0-x86-mingw32) gosu (0.13.3) gosu (0.13.3-x86-mingw32) - oily_png (1.2.1) - chunky_png (~> 1.3.7) opengl-bindings (1.6.6) PLATFORMS @@ -17,8 +14,7 @@ PLATFORMS DEPENDENCIES glu gosu - oily_png opengl-bindings BUNDLED WITH - 1.16.1 + 1.16.2 diff --git a/i-mic-fps.rb b/i-mic-fps.rb index 8d61862..7c37e3e 100644 --- a/i-mic-fps.rb +++ b/i-mic-fps.rb @@ -20,6 +20,25 @@ end BoundingBox = Struct.new(:min_x, :min_y, :min_z, :max_x, :max_y, :max_z) +if RUBY_VERSION < "2.5.0" + puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" + puts "|NOTICE| Ruby is #{RUBY_VERSION} not 2.5.0+..............................|Notice|" + puts "|NOTICE| Monkey Patching Float to add required '.clamp' method.|Notice|" + puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" + puts + class Float + def clamp(min, max) + if self < min + min + elsif self > max + max + else + return self + end + end + end +end + $debug = ARGV.join.include?("--debug") ? true : false require_relative "lib/common_methods"