Class: QDA::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/weft/application.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Version

Returns a new instance of Version.



8
9
10
11
12
13
14
# File 'lib/weft/application.rb', line 8

def initialize(str)
  if str =~ /(\d+)\.(\d+)\.(\d+)\s*/
    @major, @minor, @release = $1, $2, $3
  else
    raise ArgumentError.new("Invalid version string #{str}")
  end
end

Instance Attribute Details

#majorObject (readonly)

Returns the value of attribute major.



3
4
5
# File 'lib/weft/application.rb', line 3

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



3
4
5
# File 'lib/weft/application.rb', line 3

def minor
  @minor
end

#releaseObject (readonly)

Returns the value of attribute release.



3
4
5
# File 'lib/weft/application.rb', line 3

def release
  @release
end

Class Method Details

.default_versionObject



4
5
6
# File 'lib/weft/application.rb', line 4

def Version.default_version()
  self.new('0.0.0')
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/weft/application.rb', line 20

def ==(other)
  if other.kind_of?(String)
    other = Version.new(other)
  end
  self.major == other.major && 
    self.minor == other.minor && 
    self.release == other.release
end

#to_sObject



16
17
18
# File 'lib/weft/application.rb', line 16

def to_s
  [@major, @minor, @release].join('.')
end