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.
8 9 10 11 |
# File 'lib/graphql-formatter/character_string.rb', line 8 def initialize(color: nil) self.color = color @string = '' end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
4 5 6 |
# File 'lib/graphql-formatter/character_string.rb', line 4 def color @color end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
3 4 5 |
# File 'lib/graphql-formatter/character_string.rb', line 3 def string @string end |
Instance Method Details
#last_char ⇒ Object
13 14 15 |
# File 'lib/graphql-formatter/character_string.rb', line 13 def last_char chars.last end |
#to_s(colorize: true) ⇒ Object
17 18 19 |
# File 'lib/graphql-formatter/character_string.rb', line 17 def to_s(colorize: true) colorize ? string.colorize(color) : string end |