Class: Fitment::Tire
- Inherits:
-
Object
- Object
- Fitment::Tire
- Defined in:
- lib/fitment/tire.rb
Instance Attribute Summary collapse
-
#ratio ⇒ Object
(also: #aspect_ratio)
readonly
the aspect ratio is stored as an integer for easy assignment and comparison, and converted to a float for calculations.
-
#series ⇒ Object
readonly
the aspect ratio is stored as an integer for easy assignment and comparison, and converted to a float for calculations.
-
#wheel_diameter ⇒ Object
readonly
the aspect ratio is stored as an integer for easy assignment and comparison, and converted to a float for calculations.
-
#width ⇒ Object
readonly
the aspect ratio is stored as an integer for easy assignment and comparison, and converted to a float for calculations.
Class Method Summary collapse
-
.overall_diameter(width_mm, ratio_flt, wheel_in) ⇒ Object
inches.
- .ratio_int(ratio_flt) ⇒ Object
-
.sidewall_height(width_mm, ratio_flt) ⇒ Object
mm.
Instance Method Summary collapse
-
#initialize(width_mm, ratio, wheel_in) ⇒ Tire
constructor
A new instance of Tire.
-
#od_in ⇒ Object
(also: #overall_diameter)
overall diameter, mm and (in).
- #od_mm ⇒ Object
- #sh_in ⇒ Object
-
#sh_mm ⇒ Object
(also: #sidewall_height)
sidewall height, (mm) and in.
- #to_s ⇒ Object
Constructor Details
#initialize(width_mm, ratio, wheel_in) ⇒ Tire
Returns a new instance of Tire.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fitment/tire.rb', line 23 def initialize(width_mm, ratio, wheel_in) @width = width_mm if ratio < 0.99 and ratio > 0.1 @series = self.class.ratio_int(ratio) elsif ratio.is_a? Integer and ratio%5 == 0 and ratio > 10 and ratio < 99 @series = ratio else raise("unexpected ratio: #{ratio}") end @ratio = Rational(@series, 100) @wheel_diameter = wheel_in end |
Instance Attribute Details
#ratio ⇒ Object (readonly) Also known as: aspect_ratio
the aspect ratio is stored as an integer for easy assignment and comparison, and converted to a float for calculations
21 22 23 |
# File 'lib/fitment/tire.rb', line 21 def ratio @ratio end |
#series ⇒ Object (readonly)
the aspect ratio is stored as an integer for easy assignment and comparison, and converted to a float for calculations
21 22 23 |
# File 'lib/fitment/tire.rb', line 21 def series @series end |
#wheel_diameter ⇒ Object (readonly)
the aspect ratio is stored as an integer for easy assignment and comparison, and converted to a float for calculations
21 22 23 |
# File 'lib/fitment/tire.rb', line 21 def wheel_diameter @wheel_diameter end |
#width ⇒ Object (readonly)
the aspect ratio is stored as an integer for easy assignment and comparison, and converted to a float for calculations
21 22 23 |
# File 'lib/fitment/tire.rb', line 21 def width @width end |
Class Method Details
.overall_diameter(width_mm, ratio_flt, wheel_in) ⇒ Object
inches
15 16 17 |
# File 'lib/fitment/tire.rb', line 15 def self.overall_diameter(width_mm, ratio_flt, wheel_in) 2 * Fitment.inches(sidewall_height(width_mm, ratio_flt)) + wheel_in end |
.ratio_int(ratio_flt) ⇒ Object
5 6 7 |
# File 'lib/fitment/tire.rb', line 5 def self.ratio_int(ratio_flt) (ratio_flt * 100.0 / 5).round * 5 end |
.sidewall_height(width_mm, ratio_flt) ⇒ Object
mm
10 11 12 |
# File 'lib/fitment/tire.rb', line 10 def self.sidewall_height(width_mm, ratio_flt) width_mm * ratio_flt end |
Instance Method Details
#od_in ⇒ Object Also known as: overall_diameter
overall diameter, mm and (in)
51 52 53 |
# File 'lib/fitment/tire.rb', line 51 def od_in self.class.overall_diameter(@width, @ratio, @wheel_diameter).round(2) end |
#od_mm ⇒ Object
56 57 58 |
# File 'lib/fitment/tire.rb', line 56 def od_mm Fitment.mm(od_in).round(1) end |
#sh_in ⇒ Object
46 47 48 |
# File 'lib/fitment/tire.rb', line 46 def sh_in Fitment.inches(sh_mm).round(2) end |
#sh_mm ⇒ Object Also known as: sidewall_height
sidewall height, (mm) and in
41 42 43 |
# File 'lib/fitment/tire.rb', line 41 def sh_mm self.class.sidewall_height(@width, @ratio).round(1) end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/fitment/tire.rb', line 36 def to_s [[@width, @series].join('/'), @wheel_diameter].join('R') end |