Class: Pastel::AliasImporter
- Inherits:
-
Object
- Object
- Pastel::AliasImporter
- Defined in:
- lib/pastel/alias_importer.rb
Overview
A class responsible for importing color aliases
Instance Method Summary collapse
-
#import ⇒ nil
Import aliases from the environment.
-
#initialize(color, env, output = $stderr) ⇒ AliasImporter
constructor
Create alias importer.
Constructor Details
#initialize(color, env, output = $stderr) ⇒ AliasImporter
Create alias importer
12 13 14 15 16 |
# File 'lib/pastel/alias_importer.rb', line 12 def initialize(color, env, output = $stderr) @color = color @env = env @output = output end |
Instance Method Details
#import ⇒ nil
Import aliases from the environment
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pastel/alias_importer.rb', line 27 def import color_aliases = env["PASTEL_COLORS_ALIASES"] return unless color_aliases color_aliases.split(",").each do |color_alias| new_color, old_colors = color_alias.split("=") if !new_color || !old_colors output.puts "Bad color mapping `#{color_alias}`" else color.alias_color(new_color.to_sym, *old_colors.split(".").map(&:to_sym)) end end end |