Class: ColorLS::Core
- Inherits:
-
Object
- Object
- ColorLS::Core
- Defined in:
- lib/colorls/core.rb
Instance Method Summary collapse
-
#initialize(input = nil, all: false, report: false, sort: false, show: false, one_per_line: false, git_status: false, long: false, almost_all: false, tree: false, colors: []) ⇒ Core
constructor
A new instance of Core.
- #ls ⇒ Object
Constructor Details
#initialize(input = nil, all: false, report: false, sort: false, show: false, one_per_line: false, git_status: false, long: false, almost_all: false, tree: false, colors: []) ⇒ Core
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/colorls/core.rb', line 3 def initialize(input=nil, all: false, report: false, sort: false, show: false, one_per_line: false, git_status: false,long: false, almost_all: false, tree: false, colors: []) @input = input || Dir.pwd @count = {folders: 0, recognized_files: 0, unrecognized_files: 0} @all = all @almost_all = almost_all @report = report @sort = sort @show = show @one_per_line = one_per_line @long = long @tree = tree @git_status = git_status @screen_width = `tput cols`.chomp.to_i @colors = colors @contents = init_contents(@input) @max_widths = @contents.map(&:length) init_icons end |
Instance Method Details
#ls ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/colorls/core.rb', line 24 def ls return print "\n Nothing to show here\n".colorize(@colors[:empty]) if @contents.empty? if @tree print "\n" tree_traverse(@input, 0, 2) else @contents = chunkify @max_widths = @contents.transpose.map { |c| c.map(&:length).max } @contents.each { |chunk| ls_line(chunk) } end print "\n" display_report if @report true end |