Sha256: 8e9a5a5f433e2089c24b7019e44fd5cb18ff072468a96d34b26867688b6d64d6

Contents?: true

Size: 1 KB

Versions: 13

Compression:

Stored size: 1 KB

Contents

const { concat, group, indent, join, softline } = require("../../prettier");
const { makeCall } = require("../../utils");

function printConstPath(path, opts, print) {
  return join("::", path.map(print, "body"));
}

function printConstRef(path, opts, print) {
  return path.call(print, "body", 0);
}

function printDefined(path, opts, print) {
  return group(
    concat([
      "defined?(",
      indent(concat([softline, path.call(print, "body", 0)])),
      concat([softline, ")"])
    ])
  );
}

function printField(path, opts, print) {
  return group(
    concat([
      path.call(print, "body", 0),
      concat([makeCall(path, opts, print), path.call(print, "body", 2)])
    ])
  );
}

function printTopConst(path, opts, print) {
  return concat(["::", path.call(print, "body", 0)]);
}

module.exports = {
  const_path_field: printConstPath,
  const_path_ref: printConstPath,
  const_ref: printConstRef,
  defined: printDefined,
  field: printField,
  top_const_field: printTopConst,
  top_const_ref: printTopConst
};

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
prettier-1.6.1 src/ruby/nodes/constants.js
prettier-1.6.0 src/ruby/nodes/constants.js
prettier-1.5.5 src/ruby/nodes/constants.js
prettier-1.5.4 src/ruby/nodes/constants.js
prettier-1.5.3 src/ruby/nodes/constants.js
prettier-1.5.2 src/ruby/nodes/constants.js
prettier-1.5.1 src/ruby/nodes/constants.js
prettier-1.5.0 src/ruby/nodes/constants.js
prettier-1.4.0 src/ruby/nodes/constants.js
prettier-1.3.0 src/ruby/nodes/constants.js
prettier-1.2.5 src/ruby/nodes/constants.js
prettier-1.2.4 src/ruby/nodes/constants.js
prettier-1.2.3 src/ruby/nodes/constants.js