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.
27 28 29 30 31 |
# File 'lib/motion-bundler/require/resolve.rb', line 27 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.
24 25 26 |
# File 'lib/motion-bundler/require/resolve.rb', line 24 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
24 25 26 |
# File 'lib/motion-bundler/require/resolve.rb', line 24 def path @path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
24 25 26 |
# File 'lib/motion-bundler/require/resolve.rb', line 24 def version @version end |
#version_numbers ⇒ Object (readonly)
Returns the value of attribute version_numbers.
24 25 26 |
# File 'lib/motion-bundler/require/resolve.rb', line 24 def version_numbers @version_numbers end |
Instance Method Details
#<=>(other) ⇒ Object
33 34 35 36 |
# File 'lib/motion-bundler/require/resolve.rb', line 33 def <=>(other) raise "Not comparable gem paths ('#{name}' is not '#{other.name}')" unless name == other.name @version_numbers <=> other.version_numbers end |