Sha256: ea26f073fdb9c2d2c36ded4367768e7fb5a53726dfbcadd0414b7af82a7e407d
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
module Gorgyrella class Builder attr_reader :sections def initialize @anonymous_section_index = 0 @line = 1 @sections = [] append_section() end def section(name) selected_sections = sections.find_all {|s| s[:section] == name} raise "section #{name} not found!" if selected_sections.size == 0 raise "section #{name} not unique!" if selected_sections.size > 1 selected_sections.first end def append_line(text) @sections.last[:lines] << [@line, text] @line += 1 end def lines_for(section_name) section(section_name)[:lines] end def next_anonymous_section (@anonymous_section_index += 1).to_s end def append_section(params = {}) command = params[:command] || 'export' section = params[:section] || next_anonymous_section new_section = { :command => command, :section => section, :file => params[:file], :format => params[:format], :language => params[:language], :lines => [] } @sections << new_section end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gorgyrella-0.0.1 | lib/gorgyrella/builder.rb |
gorgyrella-0.0.2 | lib/gorgyrella/builder.rb |