Class: Version

Inherits:
Object
  • Object
show all
Defined in:
lib/updater/version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:) ⇒ Version

Returns a new instance of Version.



7
8
9
10
11
# File 'lib/updater/version.rb', line 7

def initialize(path:)
  @path = path
  @version = @path.split(File::SEPARATOR).last
  @contents = fetch_podspec
end

Instance Attribute Details

#contentsObject

Returns the value of attribute contents.



5
6
7
# File 'lib/updater/version.rb', line 5

def contents
  @contents
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/updater/version.rb', line 4

def path
  @path
end

#versionObject (readonly)

Returns the value of attribute version.



4
5
6
# File 'lib/updater/version.rb', line 4

def version
  @version
end

Instance Method Details

#<=>(other) ⇒ Object



17
18
19
20
21
# File 'lib/updater/version.rb', line 17

def <=>(other)
  own_version = @version.split('.').map(&:to_i)
  other_version = other.version.split('.').map(&:to_i)
  own_version <=> other_version
end

#saveObject



13
14
15
# File 'lib/updater/version.rb', line 13

def save
  File.write(podspec_path, JSON.pretty_generate(@contents))
end