Sha256: b6393ffddbea116d0e4a8f76b6dead03463b065716a6d12980bdcda737921bca

Contents?: true

Size: 553 Bytes

Versions: 12

Compression:

Stored size: 553 Bytes

Contents

# encoding: utf-8
# 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 a Fixnum
      @text = text.to_s
    end

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

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/rubocop-0.42.0/lib/rubocop/token.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/rubocop-0.42.0/lib/rubocop/token.rb
rubocop-0.42.0 lib/rubocop/token.rb
rubocop-0.41.2 lib/rubocop/token.rb
rubocop-0.41.1 lib/rubocop/token.rb
rubocop-0.41.0 lib/rubocop/token.rb
rubocop-0.40.0 lib/rubocop/token.rb
rubocop-0.39.0 lib/rubocop/token.rb
rubocop-0.38.0 lib/rubocop/token.rb
rubocop-0.37.2 lib/rubocop/token.rb
rubocop-0.37.1 lib/rubocop/token.rb
rubocop-0.37.0 lib/rubocop/token.rb