class Pastel::DecoratorChain
Collects a list of decorators for styling a string
@api private
Attributes
Public Class Methods
Source
# File lib/pastel/decorator_chain.rb, line 15 def self.empty @empty ||= self.new end
Create an empty decorator chain
@return [DecoratorChain]
@api public
Source
# File lib/pastel/decorator_chain.rb, line 22 def initialize(decorators = [].freeze) @decorators = decorators end
Create a decorator chain
@api public
Public Instance Methods
Source
# File lib/pastel/decorator_chain.rb, line 60 def ==(other) other.is_a?(self.class) && decorators == other.decorators end
Compare colors for equivalence of attributes
@return [Boolean]
@api public
Source
# File lib/pastel/decorator_chain.rb, line 31 def add(decorator) if decorators.include?(decorator) self.class.new(decorators) else self.class.new(decorators + [decorator]) end end
Add decorator
@param [String] decorator
@api public
Source
# File lib/pastel/decorator_chain.rb, line 42 def each(&block) decorators.each(&block) end
Iterate over list of decorators
@api public
Source
# File lib/pastel/decorator_chain.rb, line 51 def eql?(other) instance_of?(other.class) && decorators.eql?(other.decorators) end
Compare colors for equality of attributes
@return [Boolean]
@api public
Source
# File lib/pastel/decorator_chain.rb, line 78 def hash [self.class, decorators].hash end
Hash for this instance and its attributes
@return [Numeric]
@api public
Source
# File lib/pastel/decorator_chain.rb, line 69 def inspect "#<#{self.class.name} decorators=#{decorators.inspect}>" end
Inspect this instance attributes
@return [String]
@api public