Sha256: 67d2c7546fa6073c431475ce38696a27288c4e393d565cadd316affbf3284620

Contents?: true

Size: 429 Bytes

Versions: 1

Compression:

Stored size: 429 Bytes

Contents

# frozen_string_literal: true

module Vernacular
  module Modifiers
    # Extends Ruby syntax to allow number sigils, or ~n(...). The expression
    # inside is parsed and evaluated, and is replaced by the result.
    class NumberSigil < RegexModifier
      def initialize
        super(%r{~n\(([\d\s+-/*\(\)]+?)\)}) do |match|
          eval(match[3..-2]) # rubocop:disable Security/Eval
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vernacular-1.0.0 lib/vernacular/modifiers/number_sigil.rb