Class: ImageOptim::BinResolver::SimpleVersion
- Inherits:
-
Object
- Object
- ImageOptim::BinResolver::SimpleVersion
- Includes:
- Comparable
- Defined in:
- lib/image_optim/bin_resolver/simple_version.rb
Instance Attribute Summary collapse
-
#parts ⇒ Object
readonly
Returns the value of attribute parts.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(str) ⇒ SimpleVersion
constructor
A new instance of SimpleVersion.
- #to_s ⇒ Object
Constructor Details
#initialize(str) ⇒ SimpleVersion
Returns a new instance of SimpleVersion.
7 8 9 10 |
# File 'lib/image_optim/bin_resolver/simple_version.rb', line 7 def initialize(str) @str = String(str) @parts = @str.split('.').map(&:to_i).reverse.drop_while(&:zero?).reverse end |
Instance Attribute Details
#parts ⇒ Object (readonly)
Returns the value of attribute parts.
6 7 8 |
# File 'lib/image_optim/bin_resolver/simple_version.rb', line 6 def parts @parts end |
Instance Method Details
#<=>(other) ⇒ Object
16 17 18 19 |
# File 'lib/image_optim/bin_resolver/simple_version.rb', line 16 def <=>(other) other = self.class.new(other) unless other.is_a?(self.class) parts <=> other.parts end |
#to_s ⇒ Object
12 13 14 |
# File 'lib/image_optim/bin_resolver/simple_version.rb', line 12 def to_s @str end |