Class: JavaProperties::Parsing::Normalizer::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/java-properties/parsing/normalizer.rb

Overview

Describes a single normalization rule by replacing content

Instance Method Summary collapse

Constructor Details

#initialize(matcher, replacement = '') ⇒ Rule

Initializes a new rules base on a matching regexp and a replacement as substitution

Parameters:

  • matcher (Regexp)
  • replacement (String) (defaults to: '')


29
30
31
32
# File 'lib/java-properties/parsing/normalizer.rb', line 29

def initialize(matcher, replacement = '')
  @matcher     = matcher
  @replacement = replacement
end

Instance Method Details

#apply!(text) ⇒ String

Apply the substitution to the text in place

Parameters:

  • text (string)

Returns:

  • (String)


37
38
39
# File 'lib/java-properties/parsing/normalizer.rb', line 37

def apply!(text)
  text.gsub!(@matcher, @replacement)
end