Sha256: 54da177fc9058356f812ffd43e54fbc9c77d3d85d81254913260757d9e5f646a

Contents?: true

Size: 876 Bytes

Versions: 6

Compression:

Stored size: 876 Bytes

Contents

# encoding: utf-8

module Pastel
  # A class representing detached color
  class Detached
    include Equatable

    # Initialize a detached object
    #
    # @param [Pastel::Color] color
    #   the color instance
    # @param [Array[Symbol]] styles
    #   the styles to be applied
    #
    # @api private
    def initialize(color, *styles)
      @color  = color
      @styles = styles.dup
      freeze
    end

    # Decorate the values corresponding to styles
    #
    # @example
    #
    # @param [String] value
    #   the stirng to decorate with styles
    #
    # @return [String]
    #
    # @api public
    def call(*args)
      value = args.join
      @color.decorate(value, *styles)
    end
    alias_method :[], :call

    # @api public
    def to_proc
      self
    end

    private

    # @api private
    attr_reader :styles
  end # Detached
end # Pastel

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pastel-0.7.0 lib/pastel/detached.rb
pastel-0.6.1 lib/pastel/detached.rb
pastel-0.6.0 lib/pastel/detached.rb
pastel-0.5.3 lib/pastel/detached.rb
pastel-0.5.2 lib/pastel/detached.rb
pastel-0.5.1 lib/pastel/detached.rb