Class: Trailblazer::Generator::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/trailblazer/generator/output.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, content:) ⇒ Output

Returns a new instance of Output.



6
7
8
9
# File 'lib/trailblazer/generator/output.rb', line 6

def initialize(path:, content:)
  @path = path
  @content = content
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



4
5
6
# File 'lib/trailblazer/generator/output.rb', line 4

def content
  @content
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/trailblazer/generator/output.rb', line 4

def path
  @path
end

Instance Method Details

#saveObject



11
12
13
14
15
16
17
# File 'lib/trailblazer/generator/output.rb', line 11

def save
  FileUtils.mkdir_p(File.dirname(path))
  File.open(path, 'w') do |f|
    f.puts content
  end
  true
end