Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/hodmin/hodmin_list.rb,
lib/hodmin/hodmin_tools.rb,
lib/hodmin/hodmin_pull_config.rb

Overview

Converts string with config-Data (json-format) to nice output.

Instance Method Summary collapse

Instance Method Details

#config_from_stringObject



25
26
27
28
# File 'lib/hodmin/hodmin_pull_config.rb', line 25

def config_from_string
  return '' if strip.empty?
  JSON.parse(self).to_yaml
end

#include_cfg?(str) ⇒ Boolean

Returns:

  • (Boolean)


382
383
384
385
386
387
# File 'lib/hodmin/hodmin_tools.rb', line 382

def include_cfg?(str)
  return false if self == '' || str == ''
  h1 = JSON.parse(self)
  h2 = JSON.parse(str)
  (h2.to_a - h1.to_a).empty?
end

#setup_headerObject



54
55
56
57
58
59
60
61
# File 'lib/hodmin/hodmin_list.rb', line 54

def setup_header
  pastel = Pastel.new
  case slice(0, 2)
  when 'HD' then pastel.white(gsub(/HD./, ''))
  when 'FW' then pastel.white(gsub(/FW./, ''))
  else gsub(/AD./, '')
  end
end