class Build::Text::Substitutions::SymbolicSubstitution

Attributes

keyword[R]
value[R]

Public Class Methods

apply(text, group) click to toggle source
# File lib/build/text/substitutions.rb, line 99
def self.apply(text, group)
        substitutions = Hash[group.collect{|substitution| [substitution.keyword, substitution.value]}]

        pattern = Regexp.new(substitutions.keys.map{|key| Regexp.escape(key)}.join('|'))

        text.gsub(pattern) {|key| substitutions[key]}
end
new(keyword, value) click to toggle source
# File lib/build/text/substitutions.rb, line 80
def initialize(keyword, value)
        @keyword = keyword
        @value = value
end

Public Instance Methods

apply(text) click to toggle source
# File lib/build/text/substitutions.rb, line 95
def apply(text)
        text.gsub(@keyword, @value)
end
freeze() click to toggle source
Calls superclass method
# File lib/build/text/substitutions.rb, line 88
def freeze
        @keyword.freeze
        @value.freeze
        
        super
end