class Embryo::RubyTemplate

Public Instance Methods

text() click to toggle source
# File lib/rails-embryo/ruby_template.rb, line 3
def text
  code.join("\n") + "\n"
end

Protected Instance Methods

indent(code) click to toggle source
# File lib/rails-embryo/ruby_template.rb, line 9
def indent(code)
  if code.is_a? Array
    code.map { |sub_code| indent sub_code }
  elsif code == ""
    ""
  else
    "  " + code
  end
end
indent_section(code) click to toggle source
# File lib/rails-embryo/ruby_template.rb, line 19
def indent_section(code)
  if code.is_a? Array
    [""] + indent(code)
  else
    ["", indent(code)]
  end
end
indent_separated(code) click to toggle source
# File lib/rails-embryo/ruby_template.rb, line 27
def indent_separated(code)
  if code.is_a? Array
    code.flat_map { |c| [indent(c), ""] }[0...-1]
  else
    indent code
  end
end
method_code(name, *code) click to toggle source
# File lib/rails-embryo/ruby_template.rb, line 35
def method_code(name, *code)
  ["def #{name}", *indent(code), "end"]
end