Class: Washcloth::Formatters::ActiveRecord
- Inherits:
-
Object
- Object
- Washcloth::Formatters::ActiveRecord
- Defined in:
- lib/washcloth.rb
Instance Method Summary collapse
-
#initialize(filter) ⇒ ActiveRecord
constructor
A new instance of ActiveRecord.
- #regexp ⇒ Object
- #run(value) ⇒ Object
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
#regexp ⇒ Object
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 |