Class: AwesomePrint::Formatters::DirFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/awesome_print/formatters/dir_formatter.rb

Constant Summary

Constants inherited from BaseFormatter

BaseFormatter::DEFAULT_LIMIT_SIZE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseFormatter

#align, #get_limit_size, #indent, #indentation, #indented, #limited, #method_tuple, #outdent, #should_be_limited?

Methods included from Colorize

#colorize

Constructor Details

#initialize(dir, inspector) ⇒ DirFormatter

Returns a new instance of DirFormatter.



10
11
12
13
14
# File 'lib/awesome_print/formatters/dir_formatter.rb', line 10

def initialize(dir, inspector)
  @dir = dir
  @inspector = inspector
  @options = inspector.options
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



8
9
10
# File 'lib/awesome_print/formatters/dir_formatter.rb', line 8

def dir
  @dir
end

#inspectorObject (readonly)

Returns the value of attribute inspector.



8
9
10
# File 'lib/awesome_print/formatters/dir_formatter.rb', line 8

def inspector
  @inspector
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/awesome_print/formatters/dir_formatter.rb', line 8

def options
  @options
end

Instance Method Details

#formatObject



16
17
18
19
# File 'lib/awesome_print/formatters/dir_formatter.rb', line 16

def format
  ls = `ls -alF #{dir.path.shellescape}`
  colorize(ls.empty? ? dir.inspect : "#{dir.inspect}\n#{ls.chop}", :dir)
end