Class: TestFile::Builder
- Inherits:
-
Struct
- Object
- Struct
- TestFile::Builder
- Defined in:
- lib/test_file/builder.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #as_pdf ⇒ Object
- #delete ⇒ Object
- #exist? ⇒ Boolean
- #include?(content) ⇒ Boolean
- #path ⇒ Object
- #reader ⇒ Object
- #to_s ⇒ Object (also: #inspect)
- #with_content(content) ⇒ Object
- #writer ⇒ Object
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
22 23 24 |
# File 'lib/test_file/builder.rb', line 22 def name @name end |
Instance Method Details
#as_pdf ⇒ Object
29 30 31 |
# File 'lib/test_file/builder.rb', line 29 def as_pdf PDFBuilder.new(self) end |
#delete ⇒ Object
41 42 43 |
# File 'lib/test_file/builder.rb', line 41 def delete File.delete(path) if exist? end |
#exist? ⇒ Boolean
45 46 47 |
# File 'lib/test_file/builder.rb', line 45 def exist? File.exists?(path) end |
#include?(content) ⇒ Boolean
49 50 51 |
# File 'lib/test_file/builder.rb', line 49 def include?(content) reader.read.include?(content) end |
#path ⇒ Object
53 54 55 |
# File 'lib/test_file/builder.rb', line 53 def path name end |
#reader ⇒ Object
37 38 39 |
# File 'lib/test_file/builder.rb', line 37 def reader @reader ||= File.new(path, 'r') end |
#to_s ⇒ Object Also known as: inspect
57 58 59 |
# File 'lib/test_file/builder.rb', line 57 def to_s "TestFile #{path}" end |
#with_content(content) ⇒ Object
23 24 25 26 27 |
# File 'lib/test_file/builder.rb', line 23 def with_content(content) writer.write(content) writer.flush self end |
#writer ⇒ Object
33 34 35 |
# File 'lib/test_file/builder.rb', line 33 def writer @writer ||= File.new(path, 'w+') end |