Sha256: 2232de1a52721e33aa3afa44ec247b9f7a60f1f4c56c87461f40554c0e7adcca

Contents?: true

Size: 398 Bytes

Versions: 5

Compression:

Stored size: 398 Bytes

Contents

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

5 entries across 5 versions & 1 rubygems

Version Path
vernacular-0.1.2 lib/vernacular/modifiers/number_sigil.rb
vernacular-0.1.1 lib/vernacular/modifiers/number_sigil.rb
vernacular-0.1.0 lib/vernacular/modifiers/number_sigil.rb
vernacular-0.0.2 lib/vernacular/modifiers/number_sigil.rb
vernacular-0.0.1 lib/vernacular/modifiers/number_sigil.rb