Class: ColorLS::Core
- Inherits:
-
Object
- Object
- ColorLS::Core
- Defined in:
- lib/colorls/core.rb
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, hyperlink: false, tree_depth: nil) ⇒ 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, hyperlink: false, tree_depth: nil) ⇒ Core
Returns a new instance of Core.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/colorls/core.rb', line 5 def initialize(input, all: false, report: false, sort: false, show: false, mode: nil, git_status: false, almost_all: false, colors: [], group: nil, reverse: false, hyperlink: false, tree_depth: nil) @input = File.absolute_path(input) @count = {folders: 0, recognized_files: 0, unrecognized_files: 0} @all = all @almost_all = almost_all @hyperlink = hyperlink @report = report @sort = sort @reverse = reverse @group = group @show = show @one_per_line = mode == :one_per_line @long = mode == :long @tree = {mode: mode == :tree, depth: tree_depth} process_git_status_details(git_status) @screen_width = IO.console.winsize[1] @screen_width = 80 if @screen_width.zero? init_colors colors @contents = init_contents(input) @max_widths = @contents.map { |c| c.name.length } init_icons end |
Instance Method Details
#ls ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/colorls/core.rb', line 33 def ls return print "\n Nothing to show here\n".colorize(@colors[:empty]) if @contents.empty? if @tree[:mode] print "\n" tree_traverse(@input, 0, 1, 2) else @contents = chunkify @contents.each { |chunk| ls_line(chunk) } end display_report if @report true end |