Module: BeanStalk::Worker::Version

Includes:
Comparable
Defined in:
lib/beanstalk-worker/version_class.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#majorObject (readonly)

Returns the value of attribute major.



5
6
7
# File 'lib/beanstalk-worker/version_class.rb', line 5

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



5
6
7
# File 'lib/beanstalk-worker/version_class.rb', line 5

def minor
  @minor
end

#patchObject (readonly)

Returns the value of attribute patch.



5
6
7
# File 'lib/beanstalk-worker/version_class.rb', line 5

def patch
  @patch
end

Instance Method Details

#<=>(v) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/beanstalk-worker/version_class.rb', line 19

def <=>(v)
  [:major, :minor, :patch].each do |method|
    ans = (self.send(method) <=> v.send(method))
    return ans if ans != 0
  end
  0
end

#eql?(other) ⇒ Boolean

For hash

Returns:

  • (Boolean)


32
33
34
# File 'lib/beanstalk-worker/version_class.rb', line 32

def eql?(other)
  other.is_a?(Version) && self == other
end

#hashObject



27
28
29
# File 'lib/beanstalk-worker/version_class.rb', line 27

def hash
  to_s.hash
end

#initialize(str = "") ⇒ Object



7
8
9
# File 'lib/beanstalk-worker/version_class.rb', line 7

def initialize(str="")
  parse(str)
end

#inspectObject



11
12
13
# File 'lib/beanstalk-worker/version_class.rb', line 11

def inspect
  "#{@major}.#{@minor}.#{@patch}"
end

#to_sObject



15
16
17
# File 'lib/beanstalk-worker/version_class.rb', line 15

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