Sha256: e3df1ced6e4aa2450f34f7baefa978cb7f47c7d89cd0979330c6c187f00218a2

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

module LanguageServer
  module Protocol
    module Interface
      class Position
        def initialize(line:, character:)
          @attributes = {}

          @attributes[:line] = line
          @attributes[:character] = character

          @attributes.freeze
        end

        #
        # Line position in a document (zero-based).
        #
        # @return [number]
        def line
          attributes.fetch(:line)
        end

        #
        # Character offset on a line in a document (zero-based). Assuming that
        # the line is represented as a string, the `character` value represents
        # the gap between the `character` and `character + 1`.
        #
        # If the character value is greater than the line length it defaults back
        # to the line length.
        #
        # @return [number]
        def character
          attributes.fetch(:character)
        end

        attr_reader :attributes

        def to_hash
          attributes
        end

        def to_json(*args)
          to_hash.to_json(*args)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
language_server-protocol-3.16.0.3 lib/language_server/protocol/interface/position.rb
language_server-protocol-3.16.0.2 lib/language_server/protocol/interface/position.rb
language_server-protocol-3.16.0.1 lib/language_server/protocol/interface/position.rb
language_server-protocol-3.16.0.0 lib/language_server/protocol/interface/position.rb