Class: Fitment::Tire
- Inherits:
-
Object
- Object
- Fitment::Tire
- Defined in:
- lib/fitment/tire.rb
Instance Attribute Summary collapse
-
#ratio ⇒ Object
(also: #series, #aspect_ratio)
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_flt(ratio_int) ⇒ Object
- .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
- #ratio_flt ⇒ 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.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fitment/tire.rb', line 27 def initialize(width_mm, ratio, wheel_in) @width = width_mm if ratio < 0.99 and ratio > 0.1 @ratio = self.class.ratio_int(ratio) elsif ratio.is_a? Integer and ratio%5 == 0 and ratio > 10 and ratio < 99 @ratio = ratio else raise("unexpected ratio: #{ratio}") end @wheel_diameter = wheel_in end |
Instance Attribute Details
#ratio ⇒ Object (readonly) Also known as: series, aspect_ratio
the aspect ratio is stored as an integer for easy assignment and comparison, and converted to a float for calculations
25 26 27 |
# File 'lib/fitment/tire.rb', line 25 def ratio @ratio 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
25 26 27 |
# File 'lib/fitment/tire.rb', line 25 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
25 26 27 |
# File 'lib/fitment/tire.rb', line 25 def width @width end |
Class Method Details
.overall_diameter(width_mm, ratio_flt, wheel_in) ⇒ Object
inches
19 20 21 |
# File 'lib/fitment/tire.rb', line 19 def self.overall_diameter(width_mm, ratio_flt, wheel_in) 2 * Fitment.in(sidewall_height(width_mm, ratio_flt)) + wheel_in end |
.ratio_flt(ratio_int) ⇒ Object
9 10 11 |
# File 'lib/fitment/tire.rb', line 9 def self.ratio_flt(ratio_int) ratio_int / 100.0 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
14 15 16 |
# File 'lib/fitment/tire.rb', line 14 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)
58 59 60 |
# File 'lib/fitment/tire.rb', line 58 def od_in self.class.overall_diameter(@width, ratio_flt, @wheel_diameter).round(2) end |
#od_mm ⇒ Object
66 67 68 |
# File 'lib/fitment/tire.rb', line 66 def od_mm Fitment.mm(od_in).round(1) end |
#ratio_flt ⇒ Object
43 44 45 |
# File 'lib/fitment/tire.rb', line 43 def ratio_flt self.class.ratio_flt(@ratio) end |
#sh_in ⇒ Object
53 54 55 |
# File 'lib/fitment/tire.rb', line 53 def sh_in Fitment.in(sh_mm).round(2) end |
#sh_mm ⇒ Object Also known as: sidewall_height
sidewall height, (mm) and in
48 49 50 |
# File 'lib/fitment/tire.rb', line 48 def sh_mm self.class.sidewall_height(@width, ratio_flt).round(1) end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/fitment/tire.rb', line 39 def to_s [[@width, @ratio].join('/'), @wheel_diameter].join('R') end |