Sha256: f36fa948a00aabcebf31322090135f882ce5c40fb1741ec7aa227ad83e0eb700

Contents?: true

Size: 1.85 KB

Versions: 5

Compression:

Stored size: 1.85 KB

Contents

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.printSClass = exports.printModule = exports.printClass = void 0;
const prettier_1 = __importDefault(require("../../prettier"));
const utils_1 = require("../../utils");
const { group, hardline, indent } = prettier_1.default;
const printClass = (path, opts, print) => {
    const [, superclass, bodystmt] = path.getValue().body;
    const parts = ["class ", path.call(print, "body", 0)];
    if (superclass) {
        parts.push(" < ", path.call(print, "body", 1));
    }
    const declaration = group(parts);
    if ((0, utils_1.isEmptyBodyStmt)(bodystmt)) {
        return group([declaration, hardline, "end"]);
    }
    return group([
        declaration,
        indent([hardline, path.call(print, "body", 2)]),
        [hardline, "end"]
    ]);
};
exports.printClass = printClass;
const printModule = (path, opts, print) => {
    const node = path.getValue();
    const declaration = group(["module ", path.call(print, "body", 0)]);
    if ((0, utils_1.isEmptyBodyStmt)(node.body[1])) {
        return group([declaration, hardline, "end"]);
    }
    return group([
        declaration,
        indent([hardline, path.call(print, "body", 1)]),
        hardline,
        "end"
    ]);
};
exports.printModule = printModule;
const printSClass = (path, opts, print) => {
    const bodystmt = path.getValue().body[1];
    const declaration = ["class << ", path.call(print, "body", 0)];
    if ((0, utils_1.isEmptyBodyStmt)(bodystmt)) {
        return group([declaration, hardline, "end"]);
    }
    return group([
        declaration,
        indent([hardline, path.call(print, "body", 1)]),
        hardline,
        "end"
    ]);
};
exports.printSClass = printSClass;

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
prettier-2.0.0 dist/ruby/nodes/class.js
prettier-2.0.0.pre.rc4 dist/ruby/nodes/class.js
prettier-2.0.0.pre.rc3 dist/ruby/nodes/class.js
prettier-2.0.0.pre.rc2 dist/ruby/nodes/class.js
prettier-2.0.0.pre.rc1 dist/ruby/nodes/class.js