Class: Architecture::Replace

Inherits:
Object
  • Object
show all
Includes:
Entityable
Defined in:
lib/architecture/replace.rb

Instance Method Summary collapse

Constructor Details

#initialize(source:, search: "", content: "") ⇒ Replace

Returns a new instance of Replace.



5
6
7
8
9
# File 'lib/architecture/replace.rb', line 5

def initialize(source:, search: "", content: "")
  @entity = Entity.new(path: source)
  @search = search
  @content = content
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
# File 'lib/architecture/replace.rb', line 11

def call
  if entity.file?
    entity.write(text: content)
  else
    raise ArgumentError, "Source wasn't a file"
  end
end