lib/fitment/combo.rb in fitment-0.1.0.1 vs lib/fitment/combo.rb in fitment-0.1.1.1
- old
+ new
@@ -1,10 +1,9 @@
require 'fitment'
Fitment.autoload :Tire, 'fitment/tire'
Fitment.autoload :Wheel, 'fitment/wheel'
-Fitment.autoload :OffsetWheel, 'fitment/wheel'
module Fitment
class Combo
class ValidationError < RuntimeError; end
class DiameterMismatch < ValidationError; end
@@ -110,23 +109,17 @@
else
raise("unknown model: #{model}")
end
end
- def self.new_with_params(tread_with, ratio, diameter, width, offset,
- et: true)
+ def self.new_with_params(tread_with, ratio, diameter, width,
+ et: nil, offset: nil)
tire = Tire.new(tread_with, ratio, diameter)
- wheel = et ?
- Wheel.new(diameter, width, offset) :
- OffsetWheel.new(diameter, width, offset)
+ wheel = Wheel.new(diameter, width, et: et, offset: offset)
Combo.new(wheel: wheel, tire: tire)
end
- def self.new_with_offset(t, r, d, w, o)
- self.new_with_params(t, r, d, w, o, et: false)
- end
-
TIRE_EXCESS = 15 # extra rubber material near the bead relevant to fitment
attr_accessor :tire, :wheel, :model
def initialize(tire:, wheel:, model: :actual)
@@ -151,11 +144,11 @@
min, max45, max = self.class.tire_widths(@wheel.width, @model)
raise(MinError, "no min available for width %i" % @wheel.width) if !min
if @tire.width < min
raise(MinError, msg % [@tire.width, '<', 'min', min, @wheel.width])
end
- if max45 and @tire.ratio <= 45 and @tire.width > max45
+ if max45 and @tire.ratio <= 0.45 and @tire.width > max45
raise(Max45Error, msg % [@tire.width, '>', 'max45', max45, @wheel.width])
end
raise(MaxError, "no max available for width %i" % @wheel.width) if !max
if @tire.width > max
raise(MaxError, msg % [@tire.width, '>', 'max', max, @wheel.width])
@@ -221,7 +214,25 @@
{ wheel: wheel.map { |flt| flt.round(2) },
tire: tire.map { |flt| flt.round(2) }, }
end
alias_method(:clearance, :increase)
+
+ def report(other)
+ increase = self.increase other
+ wheel = increase.fetch :wheel
+ tire = increase.fetch :tire
+
+ rpt = []
+ rpt << "Wheel: %s > %s" % [@wheel, other.wheel]
+ rpt << " Inside extension: %.1f mm" % wheel[0]
+ rpt << " Outside extension: %.1f mm" % wheel[1]
+ rpt << " Diameter extension: %.1f mm" % wheel[2]
+ rpt << "Tire: %s > %s" % [@tire, other.tire]
+ rpt << " Inside extension: %.1f mm" % tire[0]
+ rpt << " Outside extension: %.1f mm" % tire[1]
+ rpt << " Diameter extension: %.1f mm" % tire[2]
+
+ rpt.join "\n"
+ end
end
end