Class: Brutal::File::Write

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

Overview

Brutal::File::Write

Since:

  • 1.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Write

Returns a new instance of Write.

Since:

  • 1.1.0



11
12
13
# File 'lib/brutal/file/write.rb', line 11

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Since:

  • 1.1.0



9
10
11
# File 'lib/brutal/file/write.rb', line 9

def name
  @name
end

Instance Method Details

#call(scaffold) ⇒ Object

Since:

  • 1.1.0



15
16
17
18
19
20
21
22
# File 'lib/brutal/file/write.rb', line 15

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

  true
ensure
  file.close
end