Class: ColorLS::Core
- Inherits:
-
Object
- Object
- ColorLS::Core
- Defined in:
- lib/colorls/core.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(input, all: false, report: false, sort: false, show: false, mode: nil, git_status: false, almost_all: false, colors: [], group: nil, reverse: false) ⇒ Core
constructor
A new instance of Core.
- #ls ⇒ Object
Constructor Details
#initialize(input, all: false, report: false, sort: false, show: false, mode: nil, git_status: false, almost_all: false, colors: [], group: nil, reverse: false) ⇒ Core
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/colorls/core.rb', line 3 def initialize(input, all: false, report: false, sort: false, show: false, mode: nil, git_status: false, almost_all: false, colors: [], group: nil, reverse: false) @input = File.absolute_path(input) @count = {folders: 0, recognized_files: 0, unrecognized_files: 0} @all = all @almost_all = almost_all @report = report @sort = sort @reverse = reverse @group = group @show = show @one_per_line = mode == :one_per_line @long = mode == :long @tree = mode == :tree process_git_status_details(git_status) @screen_width = IO.console.winsize[1] @screen_width = 80 if @screen_width.zero? @colors = colors @contents = init_contents(input) @max_widths = @contents.map { |c| c.name.length } init_icons end |
Instance Method Details
#ls ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/colorls/core.rb', line 30 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 @contents.each { |chunk| ls_line(chunk) } end display_report if @report true end |