Class: ImageOptim::Pack::Path
- Inherits:
-
Object
- Object
- ImageOptim::Pack::Path
- Defined in:
- lib/image_optim/pack.rb
Overview
Path to binary, last two parts are expect to be os/arch
Instance Attribute Summary collapse
-
#arch ⇒ Object
readonly
Inteded architecture.
-
#os ⇒ Object
readonly
Intended os.
-
#path ⇒ Object
readonly
Path provided to initialize as FSPath.
Instance Method Summary collapse
-
#all_bins_failing? ⇒ Boolean
Return true if all bins can’t execute and return version.
-
#all_bins_working? ⇒ Boolean
Return true if all bins can execute and return version.
-
#bins ⇒ Object
Cached array of BinResolver::Bin instances for each bin.
-
#failing_bins ⇒ Object
List of bins which can’t execute and return version.
-
#initialize(path) ⇒ Path
constructor
Receive path, use last part for arch and last but one part for os.
-
#to_s ⇒ Object
Return path converted to string.
-
#working_bins ⇒ Object
List of bins which can execute and return version.
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
#arch ⇒ Object (readonly)
Inteded architecture
19 20 21 |
# File 'lib/image_optim/pack.rb', line 19 def arch @arch end |
#os ⇒ Object (readonly)
Intended os
16 17 18 |
# File 'lib/image_optim/pack.rb', line 16 def os @os end |
#path ⇒ Object (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
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
40 41 42 |
# File 'lib/image_optim/pack.rb', line 40 def all_bins_working? bins.all?(&:version) end |
#bins ⇒ Object
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_bins ⇒ Object
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_s ⇒ Object
Return path converted to string
28 29 30 |
# File 'lib/image_optim/pack.rb', line 28 def to_s path.to_s end |
#working_bins ⇒ Object
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 |