Class: Washcloth::Formatters::ActiveRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/washcloth.rb

Instance Method Summary collapse

Constructor Details

#initialize(filter) ⇒ ActiveRecord

Returns a new instance of ActiveRecord.



49
50
51
# File 'lib/washcloth.rb', line 49

def initialize(filter)
  @filter = filter
end

Instance Method Details

#regexpObject



53
54
55
# File 'lib/washcloth.rb', line 53

def regexp
  / #{@filter.name}: "(?<inner>.*)"/mi
end

#run(value) ⇒ Object



57
58
59
60
61
62
# File 'lib/washcloth.rb', line 57

def run(value)
  value.gsub(regexp) do |match|
    last_match = Regexp.last_match[:inner]
    match.sub(last_match, @filter.filter[last_match])
  end
end