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
  | ( -\> | do ) $
}xo
ELIXIR_OUTDENT =
%r{ ^ ( #{OUTDENT_KEYWORDS.join("|")} | \} ) \b }xo

Instance Method Summary collapse

Instance Method Details

#indent?(lines) ⇒ Boolean

Returns:

  • (Boolean)


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

def indent?(lines)
  lines.last =~ ELIXIR_INDENT
end

#outdent?(lines) ⇒ Boolean

Returns:

  • (Boolean)


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

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