class PathPrinter
Generator for print key-value pairs
Public Class Methods
str(data)
click to toggle source
# File lib/overpath/path_printer.rb, line 6 def str(data) string(data, false, true) end
str_del(data)
click to toggle source
# File lib/overpath/path_printer.rb, line 10 def str_del(data) string_with_mark_deletion(data, false, true, '', true) end
str_mark(data, mark)
click to toggle source
# File lib/overpath/path_printer.rb, line 14 def str_mark(data, mark) string_with_mark(data, false, true, mark) end
string(data, is_list, escaped)
click to toggle source
# File lib/overpath/path_printer.rb, line 18 def string(data, is_list, escaped) string_with_mark(data, is_list, escaped, '') end
string_from_key_and_value(key_value, escaped, mark, deletion)
click to toggle source
# File lib/overpath/path_printer.rb, line 48 def string_from_key_and_value(key_value, escaped, mark, deletion) value = (escaped ? Shellwords.escape(key_value[1]) : key_value[1]) mark = (mark == key_value[0] ? " \u{2764}" : '') deletion_mark = (deletion ? " \u{2716}" : '') "\"#{key_value[0]}\" => \"#{value}\"#{mark}#{deletion_mark}" end
string_from_key_or_value(string, escaped, mark, deletion)
click to toggle source
# File lib/overpath/path_printer.rb, line 55 def string_from_key_or_value(string, escaped, mark, deletion) string += (mark == string ? " \u{2764}" : '') string += (deletion ? " \u{2716}" : '') (escaped ? Shellwords.escape(string) : string) end
string_from_key_value(o, escaped, mark, deletion)
click to toggle source
# File lib/overpath/path_printer.rb, line 38 def string_from_key_value(o, escaped, mark, deletion) line = nil if o.is_a?(Array) && o.size == 2 line = string_from_key_and_value(o, escaped, mark, deletion) elsif o.is_a?(String) line = string_from_key_or_value(o, escaped, mark, deletion) end line end
string_with_mark(data, is_list, escaped, mark)
click to toggle source
# File lib/overpath/path_printer.rb, line 22 def string_with_mark(data, is_list, escaped, mark) string_with_mark_deletion(data, is_list, escaped, mark, false) end
string_with_mark_deletion(data, is_list, escaped, mark, deletion)
click to toggle source
# File lib/overpath/path_printer.rb, line 26 def string_with_mark_deletion(data, is_list, escaped, mark, deletion) output = [] if is_list data.each do |o| output << string_from_key_value(o, escaped, mark, deletion) end else output << string_from_key_value(data, escaped, mark, deletion) end output end