Class: Pastel::Detached
- Inherits:
-
Object
- Object
- Pastel::Detached
- Defined in:
- lib/pastel/detached.rb
Overview
A class representing detached color
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compare detached objects for equivalence of attributes.
-
#call(*args) ⇒ String
(also: #[])
Decorate the values corresponding to styles.
-
#eql?(other) ⇒ Boolean
Compare detached objects for equality of attributes.
-
#hash ⇒ Numeric
Hash for this instance and its attributes.
-
#initialize(color, *styles) ⇒ Detached
constructor
private
Initialize a detached object.
-
#inspect ⇒ String
Inspect this instance attributes.
- #to_proc ⇒ Object
Constructor Details
#initialize(color, *styles) ⇒ Detached
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a detached object
14 15 16 17 18 |
# File 'lib/pastel/detached.rb', line 14 def initialize(color, *styles) @color = color @styles = styles.dup freeze end |
Instance Method Details
#==(other) ⇒ Boolean
Compare detached objects for equivalence of attributes
57 58 59 |
# File 'lib/pastel/detached.rb', line 57 def ==(other) other.is_a?(self.class) && styles == other.styles end |
#call(*args) ⇒ String Also known as: []
Decorate the values corresponding to styles
32 33 34 35 |
# File 'lib/pastel/detached.rb', line 32 def call(*args) value = args.join @color.decorate(value, *styles) end |
#eql?(other) ⇒ Boolean
Compare detached objects for equality of attributes
48 49 50 |
# File 'lib/pastel/detached.rb', line 48 def eql?(other) instance_of?(other.class) && styles.eql?(other.styles) end |
#hash ⇒ Numeric
Hash for this instance and its attributes
75 76 77 |
# File 'lib/pastel/detached.rb', line 75 def hash [self.class, styles].hash end |
#inspect ⇒ String
Inspect this instance attributes
66 67 68 |
# File 'lib/pastel/detached.rb', line 66 def inspect "#<#{self.class.name} styles=#{styles.inspect}>" end |
#to_proc ⇒ Object
39 40 41 |
# File 'lib/pastel/detached.rb', line 39 def to_proc self end |