Module: SuperDiff::Helpers
- Defined in:
- lib/super_diff/helpers.rb
Class Method Summary collapse
- .plural_type_for(value) ⇒ Object
-
.style(*args, color_enabled: true, **opts, &block) ⇒ Object
TODO: Simplify this.
Class Method Details
.plural_type_for(value) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/super_diff/helpers.rb', line 23 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(*args, color_enabled: true, **opts, &block) ⇒ Object
TODO: Simplify this
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/super_diff/helpers.rb', line 4 def self.style(*args, color_enabled: true, **opts, &block) klass = if color_enabled && Csi.color_enabled? Csi::ColorizedDocument else Csi::UncolorizedDocument end document = klass.new.extend(ColorizedDocumentExtensions) if block document.__send__(:evaluate_block, &block) else document.colorize(*args, **opts) end document end |