all files / src/detector/ number-expression.js

94.59% Statements 35/37
100% Branches 10/10
88.89% Functions 16/18
86.67% Lines 13/15
5 statements, 2 functions, 5 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91              10076697×             10076697×             8424779×             1690089×             1651918×             1651918×                                         4985939×             4985939×             1748751×             1748751×        
/**
 * 数値表現を提供します。
 */
class NumberExpression {
    /**
     * 整数表現を取得します。
     */
    static get integer() {
        return "-?[0-9]+";
    }
 
    /**
     * 小数表現を取得します。
     */
    static get decimal() {
        return "(-?[0-9]+(\\.[0-9]+)|\\.[0-9]+)";
    }
 
    /**
     * 数値表現を取得します。
     */
    static get numeric() {
        return `(${NumberExpression.integer}|${NumberExpression.decimal})`;
    }
 
    /**
     * マージン付き数値表現を取得します。
     */
    static get numericWithMargins() {
        return `\\s*${NumberExpression.numeric}\\s*`;
    }
 
    /**
     * 角度表現を取得します。
     */
    static get degree() {
        return `(${NumberExpression.integer}|${NumberExpression.decimal})(deg)?`;
    }
 
    /**
     * マージン付き角度表現を取得します。
     */
    static get degreeWithMargins() {
        return `\\s*${NumberExpression.degree}\\s*`;
    }
 
    /**
     * 角度表現を取得します。
     */
    static get turn() {
        return `(${NumberExpression.integer}|${NumberExpression.decimal})(turn)`;
    }
 
    /**
     * マージン付き角度表現を取得します。
     */
    static get turnWithMargins() {
        return `\\s*${NumberExpression.turn}\\s*`;
    }
 
    /**
     * パーセント数値表現を取得します。
     */
    static get percent() {
        return `${NumberExpression.numeric}%`;
    }
 
    /**
     * マージン付きパーセント数値表現を取得します。
     */
    static get percentWithMargins() {
        return `\\s*${NumberExpression.percent}\\s*`;
    }
 
    /**
     * パーセント許容数値表現を取得します。
     */
    static get questionablePercent() {
        return `${NumberExpression.numeric}%?`;
    }
 
    /**
     * マージン付きパーセント許容数値表現を取得します。
     */
    static get questionablePercentWithMargins() {
        return `\\s*${NumberExpression.questionablePercent}\\s*`;
    }
}
 
export { NumberExpression };