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
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
#arch ⇒ Object (readonly)
Inteded architecture
17 18 19 |
# File 'lib/image_optim/pack.rb', line 17 def arch @arch end |
#os ⇒ Object (readonly)
Intended os
14 15 16 |
# File 'lib/image_optim/pack.rb', line 14 def os @os end |
#path ⇒ Object (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
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
38 39 40 |
# File 'lib/image_optim/pack.rb', line 38 def all_bins_working? bins.all?(&:version) end |
#bins ⇒ Object
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_bins ⇒ Object
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_s ⇒ Object
Return path converted to string
26 27 28 |
# File 'lib/image_optim/pack.rb', line 26 def to_s path.to_s end |
#working_bins ⇒ Object
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 |