class ComponentEmbeddedRuby::UnexpectedTokenError

Attributes

expected[R]
got[R]

Public Class Methods

new(expected, got) click to toggle source
# File lib/component_embedded_ruby/unexpected_token_error.rb, line 7
def initialize(expected, got)
  @expected = expected
  @got = got
end

Public Instance Methods

message() click to toggle source
# File lib/component_embedded_ruby/unexpected_token_error.rb, line 12
    def message
      <<~MESSAGE.strip
        Unexpected token at line #{got.position.line}, column #{got.position.column}
        Got `#{got.value}`#{expected_message}
      MESSAGE
    end

Private Instance Methods

expected_message() click to toggle source
# File lib/component_embedded_ruby/unexpected_token_error.rb, line 21
def expected_message
  " but expected #{user_readable_expected}" unless expected.nil?
end
user_readable_expected() click to toggle source
# File lib/component_embedded_ruby/unexpected_token_error.rb, line 25
def user_readable_expected
  case expected
  when :open_carrot
    "`<`"
  when :close_carrot
    "`>`"
  when :equals
    "`=`"
  when :slash
    "`/`"
  else
    expected
  end
end