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.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace) ⇒ ModuleFormatter

Returns a new instance of ModuleFormatter.



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

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

Class Method Details

.indent(length = 0) ⇒ Object



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

def self.indent length = 0
  "  " * length
end

Instance Method Details

#render(content) ⇒ Object



21
22
23
# File 'lib/gemsmith/gem/module_formatter.rb', line 21

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