Module: Makit::Files
- Defined in:
- lib/makit/files.rb
Overview
This class provide methods for working with the system Environment.
Constant Summary collapse
- CSPROJ =
[].freeze
Class Method Summary collapse
-
.show ⇒ Object
show all the files constants in a nicely formatted table format with the name of the constant and the value.
Class Method Details
.show ⇒ Object
show all the files constants in a nicely formatted table format with the name of the constant and the value
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/makit/files.rb', line 24 def self.show # Array of constant names (symbols) constant_names = [:CSPROJ] # Find the length of the longest constant name and add 1 max_length = constant_names.map(&:to_s).max_by(&:length).length + 1 # Iterate through each constant name constant_names.each do |constant_name| constant_value = const_get(constant_name) # Fetch the value of the constant constant_value = constant_value.colorize(:green) if !constant_value.nil? && File.exist?(constant_value) # Print the constant name right justified to the max_length puts "#{constant_name.to_s.rjust(max_length)} = #{constant_value}" rescue NameError # Handle the case where the constant is not defined puts "#{constant_name.to_s.rjust(max_length)} = [Constant not defined]" end end |