Module: HashBrowns::DisplayHelpers

Defined in:
lib/hashbrowns/helpers/display_helpers.rb

Instance Method Summary collapse

Instance Method Details

#convert_status(value) ⇒ Object



27
28
29
30
31
# File 'lib/hashbrowns/helpers/display_helpers.rb', line 27

def convert_status(value)
  value = value.to_s
  return HashBrowns.conf.status_hash[value] if HashBrowns.conf.status_hash.has_key?(value)
  return value
end

#display_name(name, table) ⇒ Object



33
34
35
36
37
38
# File 'lib/hashbrowns/helpers/display_helpers.rb', line 33

def display_name(name, table)
  names = HashBrowns.conf.pretty_names[name]
  return name unless names
  return names["all"] if names.has_key?("all")
  return names[table] ? names[table] : name
end

#header_styles(header) ⇒ Object



12
13
14
# File 'lib/hashbrowns/helpers/display_helpers.rb', line 12

def header_styles(header)
  return HashBrowns.conf.header_styles[header].to_a.join(" ")
end

#importantize(key, value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/hashbrowns/helpers/display_helpers.rb', line 16

def importantize(key, value)
  value = value.downcase if HashBrowns.conf.ignore_important_case && value.kind_of?(String)
  #puts "k: #{key}, v: #{value}"
  return "nil key" if key.nil?
  return "nil value" if value.nil?
  return "#{key} not important" unless HashBrowns.conf.important.has_key?(key)
  return "#{convert_status(HashBrowns.conf.important[key].call(value))}" if HashBrowns.conf.important[key].kind_of?(Proc)
  return "#{value} not important for #{key}" unless HashBrowns.conf.important[key].has_key?(value)
  return "#{convert_status(HashBrowns.conf.important[key][value])}"
end

#table_stylesObject



4
5
6
# File 'lib/hashbrowns/helpers/display_helpers.rb', line 4

def table_styles
  return HashBrowns.conf.table_styles.to_a.join(" ")
end

#table_with_header_stylesObject



8
9
10
# File 'lib/hashbrowns/helpers/display_helpers.rb', line 8

def table_with_header_styles
  return HashBrowns.conf.table_with_header_styles.to_a.join(" ")
end