Class: VagrantBoxVersion::VersionString

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/vagrant_box_version/version-checking.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ VersionString

Returns a new instance of VersionString.



13
14
15
16
# File 'lib/vagrant_box_version/version-checking.rb', line 13

def initialize(string)
  @build = string.strip[/[^-]*/].to_i
  @hash = if string.include? "-" then string.strip.split("-")[1] else "" end
end

Instance Attribute Details

#buildObject (readonly)

Returns the value of attribute build.



10
11
12
# File 'lib/vagrant_box_version/version-checking.rb', line 10

def build
  @build
end

#hashObject (readonly)

Returns the value of attribute hash.



10
11
12
# File 'lib/vagrant_box_version/version-checking.rb', line 10

def hash
  @hash
end

Instance Method Details

#<=>(other) ⇒ Object



22
23
24
# File 'lib/vagrant_box_version/version-checking.rb', line 22

def <=>(other)
  build <=> other.build
end

#to_sObject



18
19
20
# File 'lib/vagrant_box_version/version-checking.rb', line 18

def to_s
  "#@build-#@hash"
end