Sha256: b105818771c0fbf31add8f4157b5ec708e267d63f94d1599cd2300affd147119

Contents?: true

Size: 1.1 KB

Versions: 70

Compression:

Stored size: 1.1 KB

Contents

# require "eitil_integrate/application_exporter/helpers"

require "eitil_integrate/application_exporter/initialize"

module EitilIntegrate::RubyXL
  class ApplicationExporter 

    def array_to_indexed_hash(array)
      array = array_nils_substituted(array)
      array = array_values_strf(array)
      array.flatten.map.with_index { |item, index| { "#{index}": item } }.inject &:merge
    end

    def array_nils_substituted(array)
      array.map { |value| value || '' }
    end

    def array_values_strf(array)
      array.map &:to_s
    end

    def sanitize_int(integer)
      (integer.nan? || integer.infinite?) ? 0 : integer
    end

    def pretty_date_range
      date_range.to_s.gsub '..', ' – '
    end

    def strf_date_range
      date_range.map &:to_s
    end

    def double_digit_time(time)
      time.to_s.length == 1 ? "0#{time}" : time.to_s
    end

    def format_minutes(minutes)
      hours   = double_digit_time(minutes / 60)
      minutes = double_digit_time(minutes % 60)
      "#{hours}:#{minutes}"
    end

    def name_sheet(name='Worksheet')
      sheet.sheet_name = name
    end
 
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
eitil-2.0.6 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-2.0.5 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-2.0.4 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-2.0.3 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-2.0.2 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-2.0.1 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-2.0.0 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.4.1 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.4.0 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.3.12 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.3.11 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.3.10 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.3.9 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.3.8 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.3.7 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.3.6 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.3.5 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.3.4 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.3.3 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
eitil-1.3.2 eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb