Class: HtmlFormatter::ElixirIndenter

Inherits:
Object
  • Object
show all
Defined in:
lib/htmlformatter/elixir_indenter.rb

Constant Summary collapse

INDENT_KEYWORDS =
%w[ else ]
OUTDENT_KEYWORDS =
%w[ else end ]
ELIXIR_INDENT =
%r{
  ^ ( #{INDENT_KEYWORDS.join("|")} )\b
  | ^ ( \w+\s*=\s*form\_for )
  | ( -\> | do ) $
}xo
ELIXIR_OUTDENT =
%r{ ^ ( #{OUTDENT_KEYWORDS.join("|")} | \} ) \b }xo

Instance Method Summary collapse

Instance Method Details

#indent?(lines) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/htmlformatter/elixir_indenter.rb', line 16

def indent?(lines)
  lines.join("\n") =~ ELIXIR_INDENT
end

#outdent?(lines) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/htmlformatter/elixir_indenter.rb', line 12

def outdent?(lines)
  lines.first =~ ELIXIR_OUTDENT
end