Class: Gem::Requirement

Inherits:
Micro::YAMLable show all
Defined in:
lib/microgem/requirement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Micro::YAMLable

[], inherited

Instance Attribute Details

#requirementsObject (readonly)

Returns the value of attribute requirements.



3
4
5
# File 'lib/microgem/requirement.rb', line 3

def requirements
  @requirements
end

Instance Method Details

#==(other) ⇒ Object



5
6
7
# File 'lib/microgem/requirement.rb', line 5

def ==(other)
  @requirements == other.requirements
end

#marshal_load(requirements) ⇒ Object

TODO: really test this method



32
33
34
# File 'lib/microgem/requirement.rb', line 32

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

#operatorObject

Returns the operator for this the highest version.

requirement.operator # => ">="


12
13
14
# File 'lib/microgem/requirement.rb', line 12

def operator
  @requirements.first.first
end

#to_sObject

Returns a ‘pretty’ string representation of the Requirement instance:

requirement.to_s # => ">= 0.8.1"


27
28
29
# File 'lib/microgem/requirement.rb', line 27

def to_s
  "#{operator} #{version}"
end

#versionObject

Returns the version that’s required at minimum.

TODO: Haven’t actually encountered the case where there are multiple required version yet, so that’s not implemented.



20
21
22
# File 'lib/microgem/requirement.rb', line 20

def version
  @requirements.first.last
end