class GraphQLFormatter::LineCollection
Attributes
lines[R]
Public Class Methods
new()
click to toggle source
# File lib/graphql-formatter/line_collection.rb, line 7 def initialize @lines = [GraphQLFormatter::LineOfCharacterStrings.new] end
Public Instance Methods
current_indent_level()
click to toggle source
# File lib/graphql-formatter/line_collection.rb, line 36 def current_indent_level current_line.indent_level end
current_line()
click to toggle source
# File lib/graphql-formatter/line_collection.rb, line 14 def current_line lines.last end
last_character()
click to toggle source
# File lib/graphql-formatter/line_collection.rb, line 40 def last_character (current_line && current_line.last_char) || (previous_line && previous_line.last_char) end
new_line(indent_level: current_indent_level, **opts)
click to toggle source
# File lib/graphql-formatter/line_collection.rb, line 18 def new_line(indent_level: current_indent_level, **opts) GraphQLFormatter::LineOfCharacterStrings.new(indent_level: indent_level, **opts).tap do |line| lines << line end end
new_string(**opts)
click to toggle source
# File lib/graphql-formatter/line_collection.rb, line 24 def new_string(**opts) current_line.new_string(**opts) end
previous_line()
click to toggle source
# File lib/graphql-formatter/line_collection.rb, line 28 def previous_line lines[-2] end
previous_string()
click to toggle source
# File lib/graphql-formatter/line_collection.rb, line 32 def previous_string current_line.previous_string || previous_line.current_string end
to_s(**opts)
click to toggle source
# File lib/graphql-formatter/line_collection.rb, line 45 def to_s(**opts) reject(&:empty?).map { |line| line.to_s(**opts) }.join("\n") end