class RubyPlots

Public Class Methods

new() click to toggle source
# File lib/rubyplots.rb, line 16
def initialize
end

Public Instance Methods

generatePlotsFor(data) click to toggle source

data can be a file or directory

# File lib/rubyplots.rb, line 20
def generatePlotsFor(data)
  dataPath = File.absolute_path(data)
  tempLatexDir = createTempDirectoryFor dataPath
  puts "RubyPlots: created temporary working directory '#{tempLatexDir}'."
  @orchestrator = Orchestrator.new(tempLatexDir)
  @filesFound = 0

  if File.directory? dataPath
    checkTypeAndGenerateForDir dataPath
  else
    checkTypeAndGenerateForFile dataPath
  end

  @orchestrator.generatePlots
  @orchestrator.savePlotsAndCleanup tempLatexDir
  return {:filesFound => @filesFound}
end

Private Instance Methods

checkTypeAndGenerateForDir(dir) click to toggle source
# File lib/rubyplots.rb, line 59
def checkTypeAndGenerateForDir(dir)
  Dir.entries(dir).each do |file|
    # We loose the full path on .entries, so rejoin.
    checkTypeAndGenerateForFile File.join(dir, file)
  end
end
checkTypeAndGenerateForFile(file) click to toggle source
# File lib/rubyplots.rb, line 52
def checkTypeAndGenerateForFile(file)
  if isRightType?(file)
    @filesFound += 1
    @orchestrator.addLatexFor(file)
  end
end
createTempDirectoryFor(fileOrDir) click to toggle source
# File lib/rubyplots.rb, line 41
def createTempDirectoryFor(fileOrDir)
  newDir = nil
  if File.directory? fileOrDir
    newDir = File.join(fileOrDir, 'RubyPlotsWorkingDir')
  else
    newDir = File.join(File.dirname(fileOrDir), 'RubyPlotsWorkingDir')
  end
  Dir.mkdir(newDir)
  return newDir
end
isRightType?(file) click to toggle source
# File lib/rubyplots.rb, line 66
def isRightType?(file)
  return File.extname(file) == ".scatterplot"
end