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



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

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

Instance Attribute Details

#archObject (readonly)

Inteded 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

Instance Method Details

#all_bins_failing?Boolean

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

Returns:

  • (Boolean)


45
46
47
# File 'lib/image_optim/pack.rb', line 45

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

#all_bins_working?Boolean

Return true if all bins can execute and return version

Returns:

  • (Boolean)


40
41
42
# File 'lib/image_optim/pack.rb', line 40

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

#binsObject

Cached array of BinResolver::Bin instances for each bin



33
34
35
36
37
# File 'lib/image_optim/pack.rb', line 33

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



55
56
57
# File 'lib/image_optim/pack.rb', line 55

def failing_bins
  bins.reject(&:version)
end

#to_sObject

Return path converted to string



28
29
30
# File 'lib/image_optim/pack.rb', line 28

def to_s
  path.to_s
end

#working_binsObject

List of bins which can execute and return version



50
51
52
# File 'lib/image_optim/pack.rb', line 50

def working_bins
  bins.select(&:version)
end