Class: Code::Format

Inherits:
Object show all
Defined in:
lib/code/format.rb

Constant Summary collapse

INDENT =
"  "
MAX_LINE_LENGTH =
80
MIN_WIDTH =
20
MAX_INLINE_STRING_LENGTH =
50
MAX_INLINE_COLLECTION_LENGTH =
40
MAX_INLINE_COLLECTION_ITEMS =
3
MAX_INLINE_CALL_ARGUMENTS_LENGTH =
80
MAX_INLINE_BLOCK_BODY_LENGTH =
40
CONTINUATION_PADDING =
4

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed) ⇒ Format



21
22
23
# File 'lib/code/format.rb', line 21

def initialize(parsed)
  @parsed = parsed || []
end

Class Method Details

.format(parsed) ⇒ Object



16
17
18
# File 'lib/code/format.rb', line 16

def format(parsed)
  new(parsed).format
end

Instance Method Details

#formatObject



25
26
27
# File 'lib/code/format.rb', line 25

def format
  enforce_line_width(format_code(@parsed, indent: 0))
end