Class: Fitment::Wheel

Inherits:
Object
  • Object
show all
Defined in:
lib/fitment/wheel.rb

Direct Known Subclasses

OffsetWheel

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(diameter_in, width_in, et = 0, bolt_pattern: "") ⇒ Wheel

Returns a new instance of Wheel.



16
17
18
19
20
21
# File 'lib/fitment/wheel.rb', line 16

def initialize(diameter_in, width_in, et = 0, bolt_pattern: "")
  @diameter = diameter_in
  @width = width_in
  @et = et
  @bolt_pattern = bolt_pattern
end

Instance Attribute Details

#bolt_patternObject

Returns the value of attribute bolt_pattern.



14
15
16
# File 'lib/fitment/wheel.rb', line 14

def bolt_pattern
  @bolt_pattern
end

#diameterObject (readonly)

Returns the value of attribute diameter.



13
14
15
# File 'lib/fitment/wheel.rb', line 13

def diameter
  @diameter
end

#etObject (readonly)

Returns the value of attribute et.



13
14
15
# File 'lib/fitment/wheel.rb', line 13

def et
  @et
end

#widthObject (readonly)

Returns the value of attribute width.



13
14
15
# File 'lib/fitment/wheel.rb', line 13

def width
  @width
end

Class Method Details

.et(offset_in, width_in) ⇒ Object



5
6
7
# File 'lib/fitment/wheel.rb', line 5

def self.et(offset_in, width_in)
  (-1 * Fitment.mm(offset_in - width_in / 2)).round
end

.offset(et_mm, width_in) ⇒ Object



9
10
11
# File 'lib/fitment/wheel.rb', line 9

def self.offset(et_mm, width_in)
  (width_in / 2 - Fitment.in(et_mm)).round(2)
end

Instance Method Details

#offsetObject



27
28
29
# File 'lib/fitment/wheel.rb', line 27

def offset
  self.class.offset(@et, @width)
end

#to_sObject



23
24
25
# File 'lib/fitment/wheel.rb', line 23

def to_s
  "#{@diameter}x#{@width} ET#{et}  #{@bolt_pattern}".strip
end