module GreenHat::ThingHelpers

Accessors / Readers

Public Instance Methods

build_path(divider = '_') click to toggle source

Format the name of this thing

# File lib/greenhat/thing/helpers.rb, line 16
def build_path(divider = '_')
  tmp_path = file.gsub("#{archive.path}/", '')

  case tmp_path.count('/')
  when 0
    tmp_path
  when 1
    tmp_path.split('/').last
  else
    tmp_path.split('/').last(2).join(divider)
  end
end
inspect() click to toggle source

Console Helper

# File lib/greenhat/thing/helpers.rb, line 6
def inspect
  [
    'Thing'.pastel(:bright_black),
    kind&.to_s&.pastel(:blue),
    type&.pastel(:bright_yellow),
    name&.pastel(:cyan)
  ].compact.join(' ')
end
type_check() click to toggle source

Check what kind of file we have

# File lib/greenhat/thing/helpers.rb, line 30
def type_check
  if info?
    :info
  elsif SuperLog.type?(path)
    :log
  else
    :raw
  end
end