Class: Approvals::Writers::TextWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/approvals/writers/text_writer.rb

Direct Known Subclasses

ArrayWriter, HashWriter, HtmlWriter, JsonWriter, XmlWriter

Instance Method Summary collapse

Instance Method Details

#extensionObject



4
5
6
# File 'lib/approvals/writers/text_writer.rb', line 4

def extension
  'txt'
end

#format(data) ⇒ Object



15
16
17
# File 'lib/approvals/writers/text_writer.rb', line 15

def format(data)
  data.to_s
end

#write(data, path) ⇒ Object



8
9
10
11
12
13
# File 'lib/approvals/writers/text_writer.rb', line 8

def write(data, path)
  FileUtils.mkdir_p(File.dirname(path))
  File.open(path, 'w') do |f|
    f.write format(data)
  end
end