push
travis-ci
265 of 287 relevant lines covered (92.33%)
39.28 hits per line
1 |
# coding: utf-8
|
|
2 |
|
|
3 |
module Pastel |
8 all except jruby-head ✔ |
4 |
# Contains logic for resolving styles applied to component
|
|
5 |
#
|
|
6 |
# Used internally by {Delegator}.
|
|
7 |
#
|
|
8 |
# @api private
|
|
9 |
class ColorResolver |
8 all except jruby-head ✔ |
10 |
# The color instance
|
|
11 |
# @api public
|
|
12 |
attr_reader :color
|
8 all except jruby-head ✔ |
13 |
|
|
14 |
# Initialize ColorResolver
|
|
15 |
#
|
|
16 |
# @param [Color] color
|
|
17 |
#
|
|
18 |
# @api private
|
|
19 |
def initialize(color) |
8 all except jruby-head ✔ |
20 |
@color = color
|
8 all except jruby-head ✔ |
21 |
end
|
|
22 |
|
|
23 |
# Resolve uncolored string
|
|
24 |
#
|
|
25 |
# @api private
|
|
26 |
def resolve(base, unprocessed_string) |
8 all except jruby-head ✔ |
27 |
if base.to_a.last == :detach |
× |
28 |
Detached.new(color, *base.to_a[0...-1]) |
× |
29 |
else
|
|
30 |
color.decorate(unprocessed_string, *base) |
× |
31 |
end
|
|
32 |
end
|
|
33 |
end # ColorResolver |
|
34 |
end # Pastel |