Class: Mumukit::Directives::Sections

Inherits:
Directive
  • Object
show all
Defined in:
lib/mumuki/laboratory/mumukit/directives.rb

Instance Method Summary collapse

Instance Method Details

#build(section, content) ⇒ Object



13
14
15
# File 'lib/mumuki/laboratory/mumukit/directives.rb', line 13

def build(section, content)
  "#{comment_type.comment "<#{section}#"}#{content}#{comment_type.comment "##{section}>"}"
end

#interpolate(section) ⇒ Object



17
18
19
# File 'lib/mumuki/laboratory/mumukit/directives.rb', line 17

def interpolate(section)
  comment_type.comment("...#{section}...")
end

#join(sections) ⇒ Object

TODO Move this behaviour to gem



5
6
7
8
9
10
11
# File 'lib/mumuki/laboratory/mumukit/directives.rb', line 5

def join(sections)
  file_declarations, file_references = sections.map do |section, content|
    [build(section, content), interpolate(section)]
  end.transpose

  file_declarations.join "\n"
end