Class: Gemsmith::Gem::ModuleFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/gemsmith/gem/module_formatter.rb

Overview

Formats single or multiple modules with correct, two-space indentation for templates.

Instance Method Summary collapse

Constructor Details

#initialize(namespace) ⇒ ModuleFormatter

Returns a new instance of ModuleFormatter.



11
12
13
14
15
# File 'lib/gemsmith/gem/module_formatter.rb', line 11

def initialize namespace
  @namespace = namespace
  @modules = namespace.split "::"
  @depth = namespace.scan("::").length
end

Instance Method Details

#render(content) ⇒ Object



17
18
19
# File 'lib/gemsmith/gem/module_formatter.rb', line 17

def render content
  "#{prefix}#{body content}#{suffix.chomp}"
end