Class: AmazingPrint::Formatters::HashFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- AmazingPrint::Formatters::HashFormatter
- Defined in:
- lib/amazing_print/formatters/hash_formatter.rb
Constant Summary
Constants inherited from BaseFormatter
BaseFormatter::DEFAULT_LIMIT_SIZE, BaseFormatter::INDENT_CACHE
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#inspector ⇒ Object
readonly
Returns the value of attribute inspector.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(hash, inspector) ⇒ HashFormatter
constructor
A new instance of HashFormatter.
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(hash, inspector) ⇒ HashFormatter
Returns a new instance of HashFormatter.
10 11 12 13 14 15 |
# File 'lib/amazing_print/formatters/hash_formatter.rb', line 10 def initialize(hash, inspector) super() @hash = hash @inspector = inspector @options = inspector. end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
8 9 10 |
# File 'lib/amazing_print/formatters/hash_formatter.rb', line 8 def hash @hash end |
#inspector ⇒ Object (readonly)
Returns the value of attribute inspector.
8 9 10 |
# File 'lib/amazing_print/formatters/hash_formatter.rb', line 8 def inspector @inspector end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/amazing_print/formatters/hash_formatter.rb', line 8 def @options end |
Instance Method Details
#format ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/amazing_print/formatters/hash_formatter.rb', line 17 def format if hash.empty? empty_hash elsif multiline_hash? multiline_hash else simple_hash end end |