Class: LockOMotion::GemPath
- Includes:
- Comparable
- Defined in:
- lib/lock-o-motion.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(path) ⇒ GemPath
constructor
A new instance of GemPath.
Constructor Details
#initialize(path) ⇒ GemPath
Returns a new instance of GemPath.
17 18 19 20 21 |
# File 'lib/lock-o-motion.rb', line 17 def initialize(path) @name, @version = File.basename(path).scan(/^(.+?)-([^-]+)$/).flatten @path = path @version_numbers = @version.split(/[^0-9]+/).collect(&:to_i) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/lock-o-motion.rb', line 14 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
14 15 16 |
# File 'lib/lock-o-motion.rb', line 14 def path @path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
14 15 16 |
# File 'lib/lock-o-motion.rb', line 14 def version @version end |
#version_numbers ⇒ Object (readonly)
Returns the value of attribute version_numbers.
14 15 16 |
# File 'lib/lock-o-motion.rb', line 14 def version_numbers @version_numbers end |
Instance Method Details
#<=>(other) ⇒ Object
23 24 25 26 |
# File 'lib/lock-o-motion.rb', line 23 def <=>(other) raise "Not comparable gem paths ('#{name}' is not '#{other.name}')" unless name == other.name @version_numbers <=> other.version_numbers end |