Module: Jade::Formatter::VariantDeclaration
- Extended by:
- Helper, VariantDeclaration
- Included in:
- VariantDeclaration
- 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
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/jade/formatter/declarations.rb', line 37 def format(node, indent:, source:) node => AST::VariantDeclaration(name:, args:) case args in nil | [] name in [AST::TypeRecord(fields:, row_var: nil)] fields .map { |k, v| "#{k}: #{format_type(v)}" } .join(', ') .then { "#{name}(#{it})" } else args .map { format_type(it) } .join(', ') .then { "#{name}(#{it})" } end end |