module ScoutHelpers

Constants

VERSION

Public Class Methods

get_current_file(path, category) click to toggle source

returns current file for a category

# File lib/scout-helpers.rb, line 6
def self.get_current_file(path, category)
  path = path.slice(0, path.size - 1) if path.end_with?('/')
  File.new(
    "#{path}/#{category}/" +
    Dir.entries("#{path}/#{category}")
      .select {|item| item.match(category)}
      .reject {|item| item.match("#{category}_current")}
      .sort
      .last
  )
end
get_last_file(path, category) click to toggle source

returns last complete file for a category

# File lib/scout-helpers.rb, line 20
def self.get_last_file(path, category)
  path = path.slice(0, path.size - 1) if path.end_with?('/')
  File.new(
    "#{path}/#{category}/" +
    Dir.entries("#{path}/#{category}")
      .select {|item| item.match(category)}
      .reject {|item| item.match("#{category}_current")}
      .sort
      .fetch(-2)
  )
end