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.
6 7 8 9 10 |
# File 'lib/geminabox/gem_version.rb', line 6 def initialize(name, number, platform) @name = name @number = number @platform = platform end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/geminabox/gem_version.rb', line 4 def name @name end |
#number ⇒ Object
Returns the value of attribute number.
4 5 6 |
# File 'lib/geminabox/gem_version.rb', line 4 def number @number end |
#platform ⇒ Object
Returns the value of attribute platform.
4 5 6 |
# File 'lib/geminabox/gem_version.rb', line 4 def platform @platform end |
Instance Method Details
#<=>(other) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/geminabox/gem_version.rb', line 20 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
29 30 31 32 |
# File 'lib/geminabox/gem_version.rb', line 29 def ==(other) return false unless other.class == self.class [name, number, platform] == [other.name, other.number, other.platform] end |
#gemfile_name ⇒ Object
34 35 36 37 |
# File 'lib/geminabox/gem_version.rb', line 34 def gemfile_name included_platform = ruby? ? nil : platform [name, number, included_platform].compact.join('-') end |
#ruby? ⇒ Boolean
12 13 14 |
# File 'lib/geminabox/gem_version.rb', line 12 def ruby? !!(platform =~ /ruby/i) end |
#version ⇒ Object
16 17 18 |
# File 'lib/geminabox/gem_version.rb', line 16 def version Gem::Version.create(number) end |