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



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

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

Instance Attribute Details

#archObject (readonly)

Inteded architecture



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

def arch
  @arch
end

#osObject (readonly)

Intended os



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

def os
  @os
end

#pathObject (readonly)

Path provided to initialize as FSPath



11
12
13
# File 'lib/image_optim/pack.rb', line 11

def path
  @path
end

Instance Method Details

#all_bins_failing?Boolean

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

Returns:

  • (Boolean)


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

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

#all_bins_working?Boolean

Return true if all bins can execute and return version

Returns:

  • (Boolean)


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

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

#binsObject

Cached array of BinResolver::Bin instances for each bin



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

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



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

def failing_bins
  bins.reject(&:version)
end

#to_sObject

Return path converted to string



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

def to_s
  path.to_s
end

#working_binsObject

List of bins which can execute and return version



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

def working_bins
  bins.select(&:version)
end