Class: Geminabox::GemVersion
- Inherits:
-
Object
- Object
- Geminabox::GemVersion
- Defined in:
- lib/geminabox/gem_version.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#number ⇒ Object
Returns the value of attribute number.
-
#platform ⇒ Object
Returns the value of attribute platform.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #gemfile_name ⇒ Object
-
#initialize(name, number, platform) ⇒ GemVersion
constructor
A new instance of GemVersion.
- #ruby? ⇒ Boolean
- #version ⇒ Object
Constructor Details
#initialize(name, number, platform) ⇒ GemVersion
Returns a new instance of GemVersion.
8 9 10 11 12 |
# File 'lib/geminabox/gem_version.rb', line 8 def initialize(name, number, platform) @name = name @number = number @platform = platform end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/geminabox/gem_version.rb', line 6 def name @name end |
#number ⇒ Object
Returns the value of attribute number.
6 7 8 |
# File 'lib/geminabox/gem_version.rb', line 6 def number @number end |
#platform ⇒ Object
Returns the value of attribute platform.
6 7 8 |
# File 'lib/geminabox/gem_version.rb', line 6 def platform @platform end |
Instance Method Details
#<=>(other) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/geminabox/gem_version.rb', line 22 def <=>(other) sort = other.name <=> name sort = version <=> other.version if sort.zero? sort = (other.ruby? && !ruby?) ? 1 : -1 if sort.zero? && ruby? != other.ruby? sort = other.platform <=> platform if sort.zero? sort end |
#==(other) ⇒ Object
31 32 33 34 |
# File 'lib/geminabox/gem_version.rb', line 31 def ==(other) return false unless other.class == self.class [name, number, platform] == [other.name, other.number, other.platform] end |
#gemfile_name ⇒ Object
36 37 38 39 |
# File 'lib/geminabox/gem_version.rb', line 36 def gemfile_name included_platform = ruby? ? nil : platform [name, number, included_platform].compact.join('-') end |
#ruby? ⇒ Boolean
14 15 16 |
# File 'lib/geminabox/gem_version.rb', line 14 def ruby? !!(platform =~ /ruby/i) end |
#version ⇒ Object
18 19 20 |
# File 'lib/geminabox/gem_version.rb', line 18 def version Gem::Version.create(number) end |