Class: Textbringer::Mark

Inherits:
Object
  • Object
show all
Defined in:
lib/textbringer/buffer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer, location) ⇒ Mark

Returns a new instance of Mark.



1750
1751
1752
1753
1754
# File 'lib/textbringer/buffer.rb', line 1750

def initialize(buffer, location)
  @buffer = buffer
  @file_name = nil
  @location = location
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



1747
1748
1749
# File 'lib/textbringer/buffer.rb', line 1747

def buffer
  @buffer
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



1747
1748
1749
# File 'lib/textbringer/buffer.rb', line 1747

def file_name
  @file_name
end

#locationObject

Returns the value of attribute location.



1748
1749
1750
# File 'lib/textbringer/buffer.rb', line 1748

def location
  @location
end

Instance Method Details

#deleteObject



1760
1761
1762
1763
1764
# File 'lib/textbringer/buffer.rb', line 1760

def delete
  if @buffer
    @buffer.marks.delete(self)
  end
end

#deleted?Boolean

Returns:



1766
1767
1768
# File 'lib/textbringer/buffer.rb', line 1766

def deleted?
  !@buffer.marks.include?(self)
end

#detachObject



1770
1771
1772
1773
1774
1775
# File 'lib/textbringer/buffer.rb', line 1770

def detach
  if @buffer
    @file_name = @buffer.file_name
    @buffer = nil
  end
end

#detached?Boolean

Returns:



1777
1778
1779
# File 'lib/textbringer/buffer.rb', line 1777

def detached?
  @buffer.nil?
end

#dupObject



1781
1782
1783
1784
1785
# File 'lib/textbringer/buffer.rb', line 1781

def dup
  mark = @buffer.new_mark
  mark.location = @location
  mark
end

#inspectObject



1756
1757
1758
# File 'lib/textbringer/buffer.rb', line 1756

def inspect
  "#<Mark:#{@buffer&.name || @file_name}:#{@location}>"
end