Method: Inspector#inspect_indent

Defined in:
lib/inspector.rb

#inspect_indent(data) ⇒ Object

行頭字下げをするべきか調べる



193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/inspector.rb', line 193

def inspect_indent(data)
  target_line_count = 0
  dont_indent_line_count = 0
  data.scan(/^[^#{IGNORE_INDENT_CHAR}]/).tap { |a|
    target_line_count = a.size
  }.each { |line|
    head = line[0]
    if head != " " && head != " "
      dont_indent_line_count += 1
    end
  }
  ratio = dont_indent_line_count / target_line_count.to_f
  return ratio > AUTO_INDENT_THRESHOLD_RATIO
end