class Pastel::Detached
A class representing detached color
Attributes
@api private
Public Class Methods
Source
# File lib/pastel/detached.rb, line 14 def initialize(color, *styles) @color = color @styles = styles.dup freeze end
Initialize a detached object
@param [Pastel::Color] color
the color instance
@param [Array] styles
the styles to be applied
@api private
Public Instance Methods
Source
# File lib/pastel/detached.rb, line 57 def ==(other) other.is_a?(self.class) && styles == other.styles end
Compare detached objects for equivalence of attributes
@return [Boolean]
@api public
Source
# File lib/pastel/detached.rb, line 32 def call(*args) value = args.join @color.decorate(value, *styles) end
Decorate the values corresponding to styles
@example
Detached(Color.new, :red, :bold).call("hello") # => "\e[31mhello\e[0m"
@param [String] value
the stirng to decorate with styles
@return [String]
@api public
Also aliased as: []
Source
# File lib/pastel/detached.rb, line 48 def eql?(other) instance_of?(other.class) && styles.eql?(other.styles) end
Compare detached objects for equality of attributes
@return [Boolean]
@api public
Source
# File lib/pastel/detached.rb, line 75 def hash [self.class, styles].hash end
Hash for this instance and its attributes
@return [Numeric]
@api public
Source
# File lib/pastel/detached.rb, line 66 def inspect "#<#{self.class.name} styles=#{styles.inspect}>" end
Inspect this instance attributes
@return [String]
@api public