Class: GraphQLFormatter::CharacterString

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/graphql-formatter/character_string.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#colorObject

Returns the value of attribute color.



6
7
8
# File 'lib/graphql-formatter/character_string.rb', line 6

def color
  @color
end

#stringObject (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_charObject



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