Module: LineEnder
- Included in:
- TestLineEnder::TLE
- Defined in:
- lib/line_ender.rb
Defined Under Namespace
Modules: Ending
Class Method Summary collapse
Instance Method Summary collapse
- #initialize ⇒ Object
- #output_to_file(input_filepath, ending, output_filename = '') ⇒ Object
- #output_to_string(input_filepath, ending) ⇒ Object
Class Method Details
.included(cls) ⇒ Object
19 20 21 |
# File 'lib/line_ender.rb', line 19 def self.included(cls) include Ending end |
Instance Method Details
#initialize ⇒ Object
16 17 |
# File 'lib/line_ender.rb', line 16 def initialize end |
#output_to_file(input_filepath, ending, output_filename = '') ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/line_ender.rb', line 23 def output_to_file(input_filepath, ending, output_filename='') raise RuntimeError, "Something is wrong with the input input filepath!" unless valid_filepath?(input_filepath) raise RuntimeError, "Something is wrong with the 'Ending' parameter passed in!" unless valid_ending?(ending) output_filepath = get_output_filepath(input_filepath, output_filename) debug_print "output filepath = #{output_filepath}" #this will only happen for an inplace file update if (output_filepath == input_filepath) raise RuntimeError, "File is not writeable!" unless File.writable?(output_filepath) end file_as_string = file_to_string(input_filepath) fixed_file_string = change_line_endings(file_as_string, ending) string_to_file(fixed_file_string, output_filepath) return true end |
#output_to_string(input_filepath, ending) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/line_ender.rb', line 40 def output_to_string(input_filepath, ending) raise RuntimeError, "Something is wrong with the input filepath!" unless valid_filepath?(input_filepath) raise RuntimeError, "Something is wrong with the 'Ending' parameter passed in!" unless valid_ending?(ending) file_as_string = file_to_string(input_filepath) change_line_endings(file_as_string, ending) end |