Class: ApprovalTests::Writers::TextWriter

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ TextWriter

Returns a new instance of TextWriter.



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

def initialize(data)
  @data = data
end

Class Method Details

.write_file(name, data) ⇒ Object



19
20
21
22
23
24
# File 'lib/approval_tests/writers/text_writer.rb', line 19

def self.write_file(name, data)
  f = File.new("#{name}", "w+")
  f.write(data)
  f.close()
  f.path
end

Instance Method Details

#get_approval_filename(basename) ⇒ Object



8
9
10
# File 'lib/approval_tests/writers/text_writer.rb', line 8

def get_approval_filename(basename)
  basename + ".approved.txt"
end

#get_received_filename(basename) ⇒ Object



12
13
14
# File 'lib/approval_tests/writers/text_writer.rb', line 12

def get_received_filename(basename)
  basename + ".received.txt"
end

#write_received_file(received) ⇒ Object



16
17
18
# File 'lib/approval_tests/writers/text_writer.rb', line 16

def write_received_file(received)
  TextWriter.write_file(received, @data)
end