Class: RuboCop::SketchUp::SketchUpVersion

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/rubocop/sketchup/sketchup_version.rb

Defined Under Namespace

Classes: InvalidVersion

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ SketchUpVersion

Returns a new instance of SketchUpVersion.



13
14
15
# File 'lib/rubocop/sketchup/sketchup_version.rb', line 13

def initialize(version)
  @version, @maintenance = parse_version(version)
end

Instance Attribute Details

#maintenanceObject (readonly)

Returns the value of attribute maintenance.



9
10
11
# File 'lib/rubocop/sketchup/sketchup_version.rb', line 9

def maintenance
  @maintenance
end

#versionObject (readonly)

Returns the value of attribute version.



9
10
11
# File 'lib/rubocop/sketchup/sketchup_version.rb', line 9

def version
  @version
end

Instance Method Details

#<=>(other) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/rubocop/sketchup/sketchup_version.rb', line 17

def <=>(other)
  if version == other.version
    maintenance <=> other.maintenance
  else
    version <=> other.version
  end
end

#to_sObject



25
26
27
28
29
30
31
32
# File 'lib/rubocop/sketchup/sketchup_version.rb', line 25

def to_s
  string_version = version < 2013 ? version.to_f : version.to_i
  if maintenance > 0
    "SketchUp #{string_version} M#{maintenance}"
  else
    "SketchUp #{string_version}"
  end
end