Class: SkadateGems::Dev::SoftwareVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/skadategems/dev/software_version.rb

Overview

Represents Skadate software version

Defined Under Namespace

Classes: CompatibilityError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version, release_date = nil, codename = nil) ⇒ SoftwareVersion

Returns a new instance of SoftwareVersion.

Parameters:

  • version (String)

    string version representation

  • release_date (Date) (defaults to: nil)

    version release date

  • codename (String) (defaults to: nil)

    software version codename



19
20
21
22
23
# File 'lib/skadategems/dev/software_version.rb', line 19

def initialize(version, release_date = nil, codename = nil)
  @major, @minor, @build = version.split('.', 3).map { |n| n.to_i }
  @release_date = release_date
  @codename = codename
end

Instance Attribute Details

#buildObject (readonly)

Returns the value of attribute build.



12
13
14
# File 'lib/skadategems/dev/software_version.rb', line 12

def build
  @build
end

#codenameObject (readonly)

Returns the value of attribute codename.



14
15
16
# File 'lib/skadategems/dev/software_version.rb', line 14

def codename
  @codename
end

#majorObject (readonly)

Returns the value of attribute major.



10
11
12
# File 'lib/skadategems/dev/software_version.rb', line 10

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



11
12
13
# File 'lib/skadategems/dev/software_version.rb', line 11

def minor
  @minor
end

#release_dateObject (readonly)

Returns the value of attribute release_date.



13
14
15
# File 'lib/skadategems/dev/software_version.rb', line 13

def release_date
  @release_date
end

Instance Method Details

#==(other) ⇒ Object

Versions equality operator



31
32
33
34
35
36
37
38
39
# File 'lib/skadategems/dev/software_version.rb', line 31

def == (other)
  return other == to_s if other.instance_of?(String)

  return false unless other.instance_of?(SoftwareVersion)

  @major == other.major &&
  @minor == other.minor &&
  @build == other.build
end

#supported?boolean

Returns true if current version is supported by ‘skadategems-dev`.

Returns:

  • (boolean)

    true if current version is supported by ‘skadategems-dev`



42
43
44
# File 'lib/skadategems/dev/software_version.rb', line 42

def supported?
  MAP.key?(to_s)
end

#to_sString

Returns version string representation.

Returns:

  • (String)

    version string representation



26
27
28
# File 'lib/skadategems/dev/software_version.rb', line 26

def to_s
  "#{@major}.#{@minor}.#{@build}"
end