Class: RailsPipeline::PipelineVersion

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/rails-pipeline/pipeline_version.rb

Overview

A thin wrapper around our version object A version has the form X_Y where

- X is the major version
- Y is the minor version

example: 1_0, 2_1, etc…

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version_string) ⇒ PipelineVersion

Returns a new instance of PipelineVersion.



14
15
16
17
# File 'lib/rails-pipeline/pipeline_version.rb', line 14

def initialize(version_string)
  # raise error?
  @major, @minor = version_string.split('_').map(&:to_i)
end

Instance Attribute Details

#majorObject (readonly)

Returns the value of attribute major.



12
13
14
# File 'lib/rails-pipeline/pipeline_version.rb', line 12

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



12
13
14
# File 'lib/rails-pipeline/pipeline_version.rb', line 12

def minor
  @minor
end

Instance Method Details

#<=>(other) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/rails-pipeline/pipeline_version.rb', line 23

def <=>(other)
  if major == other.major
    return minor <=> other.minor
  else
    return major <=> other.major
  end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/rails-pipeline/pipeline_version.rb', line 31

def eql?(other)
  return to_s.eql?(other.to_s)
end

#hashObject



35
36
37
# File 'lib/rails-pipeline/pipeline_version.rb', line 35

def hash
  return to_s.hash
end

#to_sObject



19
20
21
# File 'lib/rails-pipeline/pipeline_version.rb', line 19

def to_s
  "#{major}_#{minor}"
end