Sha256: a8af26f375f3587f1c676a849df7259655405d30eaaf51f6785d16d47c384232

Contents?: true

Size: 537 Bytes

Versions: 19

Compression:

Stored size: 537 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  # A basic wrapper around Parser's tokens.
  class Token
    attr_reader :pos, :type, :text

    def self.from_parser_token(parser_token)
      type, details = parser_token
      text, range = details
      new(range, type, text)
    end

    def initialize(pos, type, text)
      @pos = pos
      @type = type
      # Parser token "text" may be an Integer
      @text = text.to_s
    end

    def to_s
      "[[#{@pos.line}, #{@pos.column}], #{@type}, #{@text.inspect}]"
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/token.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/token.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/token.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/token.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/token.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/token.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/token.rb
rubocop-0.51.0 lib/rubocop/token.rb
rubocop-0.50.0 lib/rubocop/token.rb
rubocop-0.49.1 lib/rubocop/token.rb
rubocop-0.49.0 lib/rubocop/token.rb
rubocop-0.48.1 lib/rubocop/token.rb
rubocop-0.48.0 lib/rubocop/token.rb
rubocop-0.47.1 lib/rubocop/token.rb
rubocop-0.47.0 lib/rubocop/token.rb
rubocop-0.46.0 lib/rubocop/token.rb
rubocop-0.45.0 lib/rubocop/token.rb
rubocop-0.44.1 lib/rubocop/token.rb
rubocop-0.44.0 lib/rubocop/token.rb