class Atum::Generation::ErbContext
Public Instance Methods
break_line(line, max_line_length)
click to toggle source
# File lib/atum/generation/erb_context.rb, line 17 def break_line(line, max_line_length) line.split.reduce([]) do |lines, word| if lines.empty? || (lines[-1] + " #{word}").size > max_line_length lines << word else lines[-1] << " #{word}" && lines end end end
commentify(comment, tabs)
click to toggle source
# File lib/atum/generation/erb_context.rb, line 4 def commentify(comment, tabs) starter = (' ' * tabs) + '# ' max_line_length = 78 - (tabs * 2) comment.split("\n") .flat_map { |l| break_line(l, max_line_length) } .map { |l| starter + l.strip } .join("\n") end
method(name, params)
click to toggle source
# File lib/atum/generation/erb_context.rb, line 13 def method(name, params) "#{name}" + (params.length > 0 ? "(#{params})" : '') end