Class: Gem::Version

Inherits:
Micro::YAMLable show all
Includes:
Comparable
Defined in:
lib/microgem/version.rb

Defined Under Namespace

Classes: Requirement

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Micro::YAMLable

[], inherited

Instance Attribute Details

#versionObject (readonly) Also known as: to_s

Returns the value of attribute version.



15
16
17
# File 'lib/microgem/version.rb', line 15

def version
  @version
end

Class Method Details

.from_gem_dirname(dirname) ⇒ Object

Returns a Gem::Version from a string:

Gem::Version.from_gem_dirname('rake-0.8.1').version # => "0.8.1"


9
10
11
12
13
# File 'lib/microgem/version.rb', line 9

def self.from_gem_dirname(dirname)
  if dirname =~ /-([\d\.]+)$/
    self[:version => $1]
  end
end

Instance Method Details

#<=>(other) ⇒ Object

Compare two Version instances.



21
22
23
# File 'lib/microgem/version.rb', line 21

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

#any?Boolean

Returns whether or not any version will do.

Returns:

  • (Boolean)


26
27
28
# File 'lib/microgem/version.rb', line 26

def any?
  version == 0 || version == '0'
end

#marshal_load(version) ⇒ Object

TODO: really test this method, added for utils test



31
32
33
# File 'lib/microgem/version.rb', line 31

def marshal_load(version)
  @version = version.first
end