Class: GraphQLFormatter::CharacterString
- Inherits:
-
Object
- Object
- GraphQLFormatter::CharacterString
- Extended by:
- Forwardable
- Defined in:
- lib/graphql-formatter/character_string.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
-
#initialize(color: nil) ⇒ CharacterString
constructor
A new instance of CharacterString.
- #last_char ⇒ Object
- #to_s(colorize: true) ⇒ Object
Constructor Details
#initialize(color: nil) ⇒ CharacterString
Returns a new instance of CharacterString.
10 11 12 13 |
# File 'lib/graphql-formatter/character_string.rb', line 10 def initialize(color: nil) self.color = color @string = '' end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
6 7 8 |
# File 'lib/graphql-formatter/character_string.rb', line 6 def color @color end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
5 6 7 |
# File 'lib/graphql-formatter/character_string.rb', line 5 def string @string end |
Instance Method Details
#last_char ⇒ Object
15 16 17 |
# File 'lib/graphql-formatter/character_string.rb', line 15 def last_char chars.last end |
#to_s(colorize: true) ⇒ Object
19 20 21 |
# File 'lib/graphql-formatter/character_string.rb', line 19 def to_s(colorize: true) colorize ? string.colorize(color) : string end |