Sha256: f6a2be227fa3968b483f0cdd3c9e0e1a3b6b10eba9f776a18fc3634d5a826064
Contents?: true
Size: 835 Bytes
Versions: 9
Compression:
Stored size: 835 Bytes
Contents
# coding: utf-8 require 'equatable' module Pastel # Collects a list of decorators for styling a string # # @api private class DecoratorChain include Enumerable include Equatable def initialize(decorators = []) @decorators = decorators end # Add decorator # # @api public def add(decorator) if decorators.include?(decorator) self.class.new(decorators) else self.class.new(decorators + [decorator]) end end # Iterate over list of decorators # # @api public def each(&block) decorators.each(&block) end # Create an empty decorator chain # # @return [DecoratorChain] # # @api public def self.empty new([]) end protected attr_reader :decorators end # DecoratorChain end # Patel
Version data entries
9 entries across 9 versions & 2 rubygems