Module: DataUtilities

Included in:
Cd, Classification, CtTile, Density, Histogram, ImTile, ImmunoScoreResults, Original, StatResults, Statistic, Test
Defined in:
lib/analyzer.rb

Overview

Convinience for Mongomapper classes

export to csv

pretty printing of keys

Instance Method Summary collapse

Instance Method Details

#export(file_path) ⇒ Object

Export csv

file_path - the file to be exported to



549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
# File 'lib/analyzer.rb', line 549

def export file_path
  CSV.open(file_path, "wb") do |csv|
    headers=self.class.keys.keys.sort
    puts headers
    csv << headers
    self.class.all.each do |c|
      line=[]
      headers.each do |h|
        line<<(c[h]).to_s
      end
      csv << line
    end
    puts csv
  end
end

#ppObject



566
567
568
569
570
571
# File 'lib/analyzer.rb', line 566

def pp
  self.keys.keys.sort.each do |k|
    puts "#{k}: #{self[k]}"
  end
  nil
end

#pp_to_sObject



573
574
575
576
577
578
579
# File 'lib/analyzer.rb', line 573

def pp_to_s
  text=[]
  self.keys.keys.sort.each do |k|
    text<< " #{k}: #{self[k]};"
  end
  text.join "" 
end