Class: ScaffoldParser::Scaffolders::XSD::Parser::ModuleTemplate

Inherits:
Object
  • Object
show all
Includes:
Handlers::Utils
Defined in:
lib/scaffold_parser/scaffolders/xsd/parser/module_template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Handlers::Utils

#indent, #indent_string, #single_quote, #wrap_in_namespace

Constructor Details

#initialize(name = nil) {|_self| ... } ⇒ ModuleTemplate

Returns a new instance of ModuleTemplate.

Yields:

  • (_self)

Yield Parameters:



12
13
14
15
16
17
18
# File 'lib/scaffold_parser/scaffolders/xsd/parser/module_template.rb', line 12

def initialize(name = nil)
  @name = name
  @methods = []
  @namespaces = []

  yield self if block_given?
end

Instance Attribute Details

#methodsObject

Returns the value of attribute methods.



10
11
12
# File 'lib/scaffold_parser/scaffolders/xsd/parser/module_template.rb', line 10

def methods
  @methods
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/scaffold_parser/scaffolders/xsd/parser/module_template.rb', line 10

def name
  @name
end

#namespacesObject

Returns the value of attribute namespaces.



10
11
12
# File 'lib/scaffold_parser/scaffolders/xsd/parser/module_template.rb', line 10

def namespaces
  @namespaces
end

Instance Method Details

#to_sObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/scaffold_parser/scaffolders/xsd/parser/module_template.rb', line 20

def to_s
  f = StringIO.new

  f.puts "module #{name}"
  f.puts methods.join("\n\n")

  f.puts "end"
  string = f.string.strip

  namespaces.inject(string) { |string, n| wrap_in_namespace(string, n) }
end