Sha256: 4e72a7b4b64e762f1dc53b5ff89e9f2a7170d0844e430f112c8b058c430562b8

Contents?: true

Size: 347 Bytes

Versions: 4

Compression:

Stored size: 347 Bytes

Contents

module OsxSub
  class Substitution
    attr_reader :replace, :with

    def initialize(replace, with, on = true)
      @replace = replace
      @with = with
      @on = on
    end

    def on?
      return false if @on.is_a? String and @on.to_i <= 0
      true & @on
    end

    def sub(string)
      string.gsub(replace, with)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
osxsub-0.2.0 lib/osxsub/substitution.rb
osxsub-0.1.2 lib/osxsub/substitution.rb
osxsub-0.1.1 lib/osxsub/substitution.rb
osxsub-0.1.0 lib/osxsub/substitution.rb