Sha256: 4b032dc5781f8a910666ace67f95bef8939bad4e7c167d029693d9a939760084

Contents?: true

Size: 1.07 KB

Versions: 8

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

8 entries across 8 versions & 1 rubygems

Version Path
language_server-protocol-3.15.0.2 lib/language_server/protocol/interface/position.rb
language_server-protocol-3.15.0.1 lib/language_server/protocol/interface/position.rb
language_server-protocol-3.15.0.0 lib/language_server/protocol/interface/position.rb
language_server-protocol-3.14.0.2 lib/language_server/protocol/interface/position.rb
language_server-protocol-3.14.0.1 lib/language_server/protocol/interface/position.rb
language_server-protocol-3.14.0.0 lib/language_server/protocol/interface/position.rb
language_server-protocol-3.12.0.0 lib/language_server/protocol/interface/position.rb
language_server-protocol-3.7.0.0 lib/language_server/protocol/interface/position.rb