Class: Wlog::ReplacePattern

Inherits:
Commandable show all
Defined in:
lib/wlog/commands/replace_pattern.rb

Overview

Author:

  • Simon Symeonidis

Instance Method Summary collapse

Constructor Details

#initialize(db, id, oldpat, newpat) ⇒ ReplacePattern

Returns a new instance of ReplacePattern.



8
9
10
# File 'lib/wlog/commands/replace_pattern.rb', line 8

def initialize(db, id, oldpat, newpat)
  @db, @id, @oldpat, @newpat = db, id, oldpat, newpat
end

Instance Method Details

#executeObject



12
13
14
15
16
# File 'lib/wlog/commands/replace_pattern.rb', line 12

def execute
  log_entry = LogEntry.find(@db, @id)
  log_entry.description.gsub!(@oldpat, @newpat)
  log_entry.update
end