class PathGenerator

Attributes

day[R]
filepath[R]
month[R]
results_path[R]
timestamp[R]
year[R]

Public Class Methods

call(filepath, results_path, ymd) click to toggle source
# File lib/path_generator.rb, line 4
def self.call(filepath, results_path, ymd)
  new(filepath, results_path, ymd).call
end
new(filepath, results_path, ymd) click to toggle source
# File lib/path_generator.rb, line 8
def initialize(filepath, results_path, ymd)
  @filepath = filepath
  @results_path = results_path
  @year = ymd & 0b100 != 0
  @month = ymd & 0b010 != 0
  @day = ymd & 0b001 != 0
  @timestamp = Time.now
end

Public Instance Methods

call() click to toggle source
# File lib/path_generator.rb, line 17
def call
  File.join(produce_path, produce_dirname)
end

Private Instance Methods

produce_dirname() click to toggle source
# File lib/path_generator.rb, line 32
def produce_dirname
  str = ""
  str += "%Y_" unless year
  str += "%m_" unless month
  str += "%d_" unless day
  str += "%H-%M-%S"
  timestamp.strftime(str)
end
produce_path() click to toggle source
# File lib/path_generator.rb, line 23
def produce_path
  parts = []
  parts.push(results_path)
  parts.push(timestamp.year.to_s) if year
  parts.push(timestamp.month.to_s) if month
  parts.push(timestamp.day.to_s) if day
  File.join(*parts)
end