Sha256: 0876390bfe1bbfd4d03d1b9a2c10a86348492a604442ecc3232d0de5dbc0a64d
Contents?: true
Size: 764 Bytes
Versions: 2
Compression:
Stored size: 764 Bytes
Contents
# frozen_string_literal: true module PrettyFeed # Provide compatibility with Polluted and Unpolluted Strings module Compat define_method(:[]) do |str, color| return ColorizedString[str] if defined?(ColorizedString) return str if str.respond_to?(color.to_sym) dstr = str.dup if defined?(Term::ANSIColor) dstr.singleton_class.send(:include, Term::ANSIColor) else dstr.singleton_class.send(:include, color_stub(str, color)) end dstr end module_function :[] private module_function def color_stub(str, color) Module.new do define_method(color.to_sym) do warn "Adding stub for missing '#{str}'.#{color}" self end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pretty_feed-1.0.1 | lib/pretty_feed/compat.rb |
pretty_feed-1.0.0 | lib/pretty_feed/compat.rb |