Class: ScaffoldParser::Scaffolders::XSD::Parser::ModuleTemplate
- Inherits:
-
Object
- Object
- ScaffoldParser::Scaffolders::XSD::Parser::ModuleTemplate
- Includes:
- Handlers::Utils
- Defined in:
- lib/scaffold_parser/scaffolders/xsd/parser/module_template.rb
Instance Attribute Summary collapse
-
#methods ⇒ Object
Returns the value of attribute methods.
-
#name ⇒ Object
Returns the value of attribute name.
-
#namespaces ⇒ Object
Returns the value of attribute namespaces.
Instance Method Summary collapse
-
#initialize(name = nil) {|_self| ... } ⇒ ModuleTemplate
constructor
A new instance of ModuleTemplate.
- #to_s ⇒ Object
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.
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
#methods ⇒ Object
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 |
#name ⇒ Object
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 |
#namespaces ⇒ Object
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_s ⇒ Object
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 |