Module: SuperDiff::Helpers

Defined in:
lib/super_diff/helpers.rb

Constant Summary collapse

COLORS =
{ normal: :plain, inserted: :green, deleted: :red }.freeze

Class Method Summary collapse

Class Method Details

.inspect_object(value_to_inspect, single_line: true) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/super_diff/helpers.rb', line 18

def self.inspect_object(value_to_inspect, single_line: true)
  case value_to_inspect
  when ::Hash
    inspect_hash(value_to_inspect, single_line: single_line)
  when String
    inspect_string(value_to_inspect)
  when ::Array
    inspect_array(value_to_inspect)
  else
    inspect_unclassified_object(value_to_inspect, single_line: single_line)
  end
end

.plural_type_for(value) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/super_diff/helpers.rb', line 9

def self.plural_type_for(value)
  case value
  when Numeric then "numbers"
  when String then "strings"
  when Symbol then "symbols"
  else "objects"
  end
end

.style(style_name, text) ⇒ Object



5
6
7
# File 'lib/super_diff/helpers.rb', line 5

def self.style(style_name, text)
  Csi::ColorHelper.public_send(COLORS.fetch(style_name), text)
end