Module: GreenHat::ThingHelpers

Included in:
Thing
Defined in:
lib/greenhat/thing/helpers.rb

Overview

Accessors / Readers

Instance Method Summary collapse

Instance Method Details

#build_path(divider = '_') ⇒ Object

Format the name of this thing



16
17
18
19
20
21
22
23
24
25
26
27
# 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

#inspectObject

Console Helper



6
7
8
9
10
11
12
13
# 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_checkObject

Check what kind of file we have



30
31
32
33
34
35
36
37
38
# File 'lib/greenhat/thing/helpers.rb', line 30

def type_check
  if info?
    :info
  elsif SuperLog.type?(path)
    :log
  else
    :raw
  end
end