Sha256: 288da724cf04316af8091860f3643a42b0b1175fdf95992de1aabdb0dd2070f1

Contents?: true

Size: 467 Bytes

Versions: 2

Compression:

Stored size: 467 Bytes

Contents

require 'wlog/commands/commandable'
require 'wlog/domain/log_entry'

module Wlog
# Command that replaces a string pattern found in an entry, with another string
# @author Simon Symeonidis
class ReplacePattern < Commandable
  def initialize(db, id, oldpat, newpat)
    @db, @id, @oldpat, @newpat = db, id, oldpat, newpat
  end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wlog-1.1.1 lib/wlog/commands/replace_pattern.rb
wlog-1.0.5 lib/wlog/commands/replace_pattern.rb