We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This code should do it...
# Fixedwidth.generate(data: input, header: header, start: start, stop: stop, delimiter: "|") do |line| # output << line # end module Fixedwidth def self.generate(options) @options = options @options[:delimiter] ||= "," @options[:data].each do |hash| string = " " * (string_length*2) # FIXME: Find of end of line! hash.sort_by { |k,v| header_positions["#{k}"][0] }.each do |k,v| positions = header_positions["#{k}"] string[positions[0],positions[1]]="#{v}" end yield(string) end end def self.string_length column_positions.last.inject(0) { |i,sum| sum += i } end def self.header_positions @header_positions ||= {}.tap do |positions| start.zip(stop).each_with_index do |item,index| a, b = item[0].to_i, item[1].to_i a = a - 1 b = b-a positions.merge!(header[index] => [a,b]) end end end end
The text was updated successfully, but these errors were encountered:
Why not issue a pull request?
Sorry, something went wrong.
No branches or pull requests
This code should do it...
The text was updated successfully, but these errors were encountered: