Sha256: 1a1cc265c43f3e44f7eb0608add2201d0289ef7f92db6cb17ca765c1d4310512
Contents?: true
Size: 1.03 KB
Versions: 222
Compression:
Stored size: 1.03 KB
Contents
module Generator class ExerciseCase module CaseHelpers protected # indent multi line workloads # # indent_lines( # [ # "string = #{input.inspect}", # "#{assert} Isogram.is_isogram?(string)" # ], 4 # ) def indent_lines(code, depth, separator = "\n") code.join(separator + ' ' * depth) end # indent multi line workloads with (unindented) blank lines # # indent_text(4, text) def indent_text(depth, text) text.lines.reduce do |obj, line| obj << (line == "\n" ? line : ' ' * depth + line) end end # generate heredoc (as part of workload) with optional indentation # # indent_heredoc(["foo", "bar"], 'TEXT', 1) def indent_heredoc(lines, delimiter, depth = 0, delimiter_method = nil) [ "<<-#{delimiter}#{delimiter_method}", lines.map { |line| ' ' * depth + line }.join("\n"), delimiter ].join("\n") end end end end
Version data entries
222 entries across 222 versions & 1 rubygems