Class: MotionBundler::Require::Resolve::GemPath
- Includes:
- Comparable
- Defined in:
- lib/motion-bundler/require/resolve.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.
29 30 31 32 33 |
# File 'lib/motion-bundler/require/resolve.rb', line 29 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.
26 27 28 |
# File 'lib/motion-bundler/require/resolve.rb', line 26 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
26 27 28 |
# File 'lib/motion-bundler/require/resolve.rb', line 26 def path @path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
26 27 28 |
# File 'lib/motion-bundler/require/resolve.rb', line 26 def version @version end |
#version_numbers ⇒ Object (readonly)
Returns the value of attribute version_numbers.
26 27 28 |
# File 'lib/motion-bundler/require/resolve.rb', line 26 def version_numbers @version_numbers end |
Instance Method Details
#<=>(other) ⇒ Object
35 36 37 38 |
# File 'lib/motion-bundler/require/resolve.rb', line 35 def <=>(other) raise "Not comparable gem paths ('#{name}' is not '#{other.name}')" unless name == other.name @version_numbers <=> other.version_numbers end |