Class: ImageOptim::Pack::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/image_optim/pack.rb

Overview

Path to binary, last two parts are expect to be os/arch

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Path

Receive path, use last part for arch and last but one part for os



25
26
27
28
# File 'lib/image_optim/pack.rb', line 25

def initialize(path)
  @path = FSPath(path)
  @os, @arch, @version = @path.basename.to_s.split('-', 3)
end

Instance Attribute Details

#archObject (readonly)

Intended architecture



19
20
21
# File 'lib/image_optim/pack.rb', line 19

def arch
  @arch
end

#osObject (readonly)

Intended os



16
17
18
# File 'lib/image_optim/pack.rb', line 16

def os
  @os
end

#pathObject (readonly)

Path provided to initialize as FSPath



13
14
15
# File 'lib/image_optim/pack.rb', line 13

def path
  @path
end

#versionObject (readonly)

Intended version



22
23
24
# File 'lib/image_optim/pack.rb', line 22

def version
  @version
end

Instance Method Details

#all_bins_failing?Boolean

Return true if all bins can’t execute and return version

Returns:

  • (Boolean)


48
49
50
# File 'lib/image_optim/pack.rb', line 48

def all_bins_failing?
  bins.none?(&:version)
end

#all_bins_working?Boolean

Return true if all bins can execute and return version

Returns:

  • (Boolean)


43
44
45
# File 'lib/image_optim/pack.rb', line 43

def all_bins_working?
  bins.all?(&:version)
end

#binsObject

Cached array of BinResolver::Bin instances for each bin



36
37
38
39
40
# File 'lib/image_optim/pack.rb', line 36

def bins
  @bins ||= bin_paths.map do |bin_path|
    BinResolver::Bin.new(bin_path.basename.to_s, bin_path.to_s)
  end
end

#failing_binsObject

List of bins which can’t execute and return version



58
59
60
# File 'lib/image_optim/pack.rb', line 58

def failing_bins
  bins.reject(&:version)
end

#to_sObject

Return path converted to string



31
32
33
# File 'lib/image_optim/pack.rb', line 31

def to_s
  path.to_s
end

#working_binsObject

List of bins which can execute and return version



53
54
55
# File 'lib/image_optim/pack.rb', line 53

def working_bins
  bins.select(&:version)
end