Class: AmazingPrint::Formatters::FileFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- AmazingPrint::Formatters::FileFormatter
- Defined in:
- lib/amazing_print/formatters/file_formatter.rb
Constant Summary
Constants inherited from BaseFormatter
BaseFormatter::DEFAULT_LIMIT_SIZE, BaseFormatter::INDENT_CACHE
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#inspector ⇒ Object
readonly
Returns the value of attribute inspector.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #format ⇒ Object
- #info ⇒ Object
-
#initialize(file, inspector) ⇒ FileFormatter
constructor
A new instance of FileFormatter.
Methods inherited from BaseFormatter
#align, #colorless_size, #get_limit_size, #indent, #indentation, #indented, #limited, #method_tuple, #outdent, #should_be_limited?
Methods included from Colorize
Constructor Details
#initialize(file, inspector) ⇒ FileFormatter
Returns a new instance of FileFormatter.
13 14 15 16 17 18 |
# File 'lib/amazing_print/formatters/file_formatter.rb', line 13 def initialize(file, inspector) super() @file = file @inspector = inspector @options = inspector. end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
11 12 13 |
# File 'lib/amazing_print/formatters/file_formatter.rb', line 11 def file @file end |
#inspector ⇒ Object (readonly)
Returns the value of attribute inspector.
11 12 13 |
# File 'lib/amazing_print/formatters/file_formatter.rb', line 11 def inspector @inspector end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/amazing_print/formatters/file_formatter.rb', line 11 def @options end |
Instance Method Details
#format ⇒ Object
20 21 22 23 |
# File 'lib/amazing_print/formatters/file_formatter.rb', line 20 def format ls = info colorize(ls.empty? ? file.inspect : "#{file.inspect}\n#{ls.chop}", :file) end |
#info ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/amazing_print/formatters/file_formatter.rb', line 25 def info if RUBY_PLATFORM.include?('mswin') "#{GetChildItem.new(@file.path)}\n" else File.directory?(file) ? `ls -adlF #{file.path.shellescape}` : `ls -alF #{file.path.shellescape}` end end |