Class: Spork::GemHelpers::GemPath
- Inherits:
-
Object
- Object
- Spork::GemHelpers::GemPath
- Includes:
- Comparable
- Defined in:
- lib/spork/gem_helpers.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#version_numbers ⇒ Object
readonly
Returns the value of attribute version_numbers.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(p) ⇒ GemPath
constructor
A new instance of GemPath.
Constructor Details
#initialize(p) ⇒ GemPath
Returns a new instance of GemPath.
7 8 9 10 11 |
# File 'lib/spork/gem_helpers.rb', line 7 def initialize(p) @path = p @name, @version = File.basename(p).scan(/^(.+?)-([^-]+)$/).flatten @version_numbers = @version.split(/[^0-9]+/).map(&:to_i) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/spork/gem_helpers.rb', line 5 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/spork/gem_helpers.rb', line 5 def path @path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/spork/gem_helpers.rb', line 5 def version @version end |
#version_numbers ⇒ Object (readonly)
Returns the value of attribute version_numbers.
5 6 7 |
# File 'lib/spork/gem_helpers.rb', line 5 def version_numbers @version_numbers end |
Instance Method Details
#<=>(other) ⇒ Object
13 14 15 16 |
# File 'lib/spork/gem_helpers.rb', line 13 def <=>(other) raise "Not comparable gem paths ('#{name}' is not '#{other.name}')" unless name == other.name @version_numbers <=> other.version_numbers end |