Class: ImageOptim::BinResolver::SimpleVersion

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/image_optim/bin_resolver/simple_version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#partsObject (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_sObject



12
13
14
# File 'lib/image_optim/bin_resolver/simple_version.rb', line 12

def to_s
  @str
end