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 24 |
# File 'lib/image_optim/pack.rb', line 20 def initialize(path) @path = FSPath(path) @os = @path.dirname.basename.to_s @arch = @path.basename.to_s 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
44 45 46 |
# File 'lib/image_optim/pack.rb', line 44 def all_bins_failing? bins.none?(&:version) end |
#all_bins_working? ⇒ Boolean
Return true if all bins can execute and return version
39 40 41 |
# File 'lib/image_optim/pack.rb', line 39 def all_bins_working? bins.all?(&:version) end |
#bins ⇒ Object
Cached array of BinResolver::Bin instances for each bin
32 33 34 35 36 |
# File 'lib/image_optim/pack.rb', line 32 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
54 55 56 |
# File 'lib/image_optim/pack.rb', line 54 def failing_bins bins.reject(&:version) end |
#to_s ⇒ Object
Return path converted to string
27 28 29 |
# File 'lib/image_optim/pack.rb', line 27 def to_s path.to_s end |
#working_bins ⇒ Object
List of bins which can execute and return version
49 50 51 |
# File 'lib/image_optim/pack.rb', line 49 def working_bins bins.select(&:version) end |