Class Neovim::LineRange
In: lib/neovim/line_range.rb
Parent: Object

Provide an enumerable interface for dealing with ranges of lines.

Methods

[]   []=   delete   each   insert   new   replace   slice   to_a  

Included Modules

Enumerable

Public Class methods

Public Instance methods

Access the line at the given index within the range.

@overload [](index)

  @param index [Integer]

@overload [](range)

  @param range [Range]

@overload [](index, length)

  @param index [Integer]
  @param length [Integer]

@example Get the first line using an index

  line_range[0] # => "first"

@example Get the first two lines using a Range

  line_range[0..1] # => ["first", "second"]

@example Get the first two lines using an index and length

  line_range[0, 2] # => ["first", "second"]

Set the line at the given index within the range.

@overload []=(index, string)

  @param index [Integer]
  @param string [String]

@overload []=(index, length, strings)

  @param index [Integer]
  @param length [Integer]
  @param strings [Array<String>]

@overload []=(range, strings)

  @param range [Range]
  @param strings [Array<String>]

@example Replace the first line using an index

  line_range[0] = "first"

@example Replace the first two lines using a Range

  line_range[0..1] = ["first", "second"]

@example Replace the first two lines using an index and length

  line_range[0, 2] = ["first", "second"]

Delete the line at the given index within the range.

@param index [Integer]

Yield each line in the range.

@yield [String] The current line @return [Array<String>]

Insert line(s) at the given index within the range.

@param index [Integer] @param lines [String]

Replace the range of lines.

@param other [Array] The replacement lines

slice(pos, len=nil)

Alias for #[]

Resolve to an array of lines as strings.

@return [Array<String>]

[Validate]