Sha256: f801d986dd91fd9ee55384d9bf629f92fc20f2e83b7cad9d2daf9ef1c0087916

Contents?: true

Size: 1.39 KB

Versions: 67

Compression:

Stored size: 1.39 KB

Contents

const AbstractGeneratorHandler = require("../AbstractGeneratorHandler");
const reserved = require("reserved-words");

class SharedClassNameHandler extends AbstractGeneratorHandler {

    generate_code(existing_string_builder, common_command, used_object, handlers) {

        used_object = used_object.substring(used_object.lastIndexOf(".") + 1);

        if (used_object.includes('#')) {
            used_object = used_object.replace("#", "");
        }

        if (used_object.includes('-')) {
            used_object = used_object.replace("-", "_");
        }

        if (this.is_numeric_char(used_object[0])) {
            let pos = 0;
            for (const [index, element] of used_object.entries()) {
                if (this.is_numeric_char(element)) {
                    pos = index
                }
                break
            }
            const new_str = used_object.slice(pos);
            used_object = new_str
        }

        if (used_object[0] === used_object[0].toUpperCase()) {
            used_object = used_object[0].toLowerCase() + used_object.slice(1)
        }

        if (!reserved.check(used_object)) {
            existing_string_builder.append(used_object)
        } else {
            throw ("SharedMethodNameHandlerError: Given name is not valid: " + used_object)
        }
    }

    is_numeric_char(c) {
        return /\d/.test(c);
    }
}

module.exports = SharedClassNameHandler

Version data entries

67 entries across 38 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.5.7 lib/javonet-ruby-sdk/Binaries/Nodejs/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.5.6 lib/javonet-ruby-sdk/Binaries/Nodejs/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.5.5 lib/javonet-ruby-sdk/Binaries/Nodejs/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.5.4 lib/javonet-ruby-sdk/Binaries/Nodejs/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.5.3 lib/javonet-ruby-sdk/Binaries/Nodejs/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.5.2 lib/javonet-ruby-sdk/Binaries/Nodejs/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.5.1 lib/javonet-ruby-sdk/Binaries/Nodejs/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.5.0 lib/javonet-ruby-sdk/Binaries/Nodejs/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.4.11 lib/javonet-ruby-sdk/Binaries/Nodejs/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.4.9 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.4.9 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.4.8 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.4.8 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.4.7 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.4.7 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.4.6 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.4.6 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/generator/handler/shared/SharedClassNameHandler.js
javonet-ruby-sdk-2.4.5 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/core/generator/handler/shared/SharedClassNameHandler.js