Module: Jade::Formatter::InterfaceDeclaration

Extended by:
Helper, InterfaceDeclaration
Included in:
InterfaceDeclaration
Defined in:
lib/jade/formatter/declarations.rb

Instance Method Summary collapse

Methods included from Helper

and_indent, dispatch_for, format_delimited, format_exposing, format_leading_comments, format_node, format_pattern, format_trailing_comment, format_type, format_type_atom, too_long?

Instance Method Details

#format(node, indent:, source:) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/jade/formatter/declarations.rb', line 130

def format(node, indent:, source:)
  node => AST::InterfaceDeclaration(name:, type_param:, functions:)

  fns_str = functions
    .map { format_node(it, indent: indent + 1, source:) }
    .join(",\n")

  [
    "interface #{name}(#{type_param.name}) with".then(&and_indent(indent)),
    fns_str,
    "end".then(&and_indent(indent)),
  ].join("\n")
end