Class: Brutal::File::Write

Inherits:
Object
  • Object
show all
Defined in:
lib/brutal/file/write.rb

Overview

Brutal::File::Write

Since:

  • 1.1.0

Constant Summary collapse

NAME =

Since:

  • 1.1.0

"test.rb"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = NAME) ⇒ Write

Returns a new instance of Write.

Since:

  • 1.1.0


16
17
18
# File 'lib/brutal/file/write.rb', line 16

def initialize(name = NAME)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Since:

  • 1.1.0


14
15
16
# File 'lib/brutal/file/write.rb', line 14

def name
  @name
end

Instance Method Details

#call(scaffold) ⇒ Object

Since:

  • 1.1.0


20
21
22
23
24
25
26
27
# File 'lib/brutal/file/write.rb', line 20

def call(scaffold)
  file = ::File.open(path, "w")
  file.write(scaffold)

  true
ensure
  file.close
end