Sha256: ccc13645ff32352491ef3a1004e81bd292a2c53d84c13a2e91a81ebbaacb5f45

Contents?: true

Size: 725 Bytes

Versions: 5

Compression:

Stored size: 725 Bytes

Contents

# frozen_string_literal: true

require_relative "detached"

module Pastel
  # Contains logic for resolving styles applied to component
  #
  # Used internally by {Delegator}.
  #
  # @api private
  class ColorResolver
    # The color instance
    # @api public
    attr_reader :color

    # Initialize ColorResolver
    #
    # @param [Color] color
    #
    # @api private
    def initialize(color)
      @color = color
    end

    # Resolve uncolored string
    #
    # @api private
    def resolve(base, unprocessed_string)
      if base.to_a.last == :detach
        Detached.new(color, *base.to_a[0...-1])
      else
        color.decorate(unprocessed_string, *base)
      end
    end
  end # ColorResolver
end # Pastel

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
lotrd-0.1.9 vendor/cache/ruby/2.6.0/gems/pastel-0.8.0/lib/pastel/color_resolver.rb
lotrd-0.1.8 vendor/cache/ruby/2.6.0/gems/pastel-0.8.0/lib/pastel/color_resolver.rb
lotrd-0.1.6 vendor/cache/ruby/2.6.0/gems/pastel-0.8.0/lib/pastel/color_resolver.rb
lotrd-0.1.5 vendor/cache/ruby/2.6.0/gems/pastel-0.8.0/lib/pastel/color_resolver.rb
pastel-0.8.0 lib/pastel/color_resolver.rb