Class: VER::Text::Range

Inherits:
Struct
  • Object
show all
Defined in:
lib/ver/text/range.rb

Constant Summary

Constants inherited from Struct

Struct::CACHE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

new

Instance Attribute Details

#bufferObject

Returns the value of attribute buffer

Returns:

  • (Object)

    the current value of buffer



3
4
5
# File 'lib/ver/text/range.rb', line 3

def buffer
  @buffer
end

#firstObject

Returns the value of attribute first

Returns:

  • (Object)

    the current value of first



3
4
5
# File 'lib/ver/text/range.rb', line 3

def first
  @first
end

#lastObject

Returns the value of attribute last

Returns:

  • (Object)

    the current value of last



3
4
5
# File 'lib/ver/text/range.rb', line 3

def last
  @last
end

Instance Method Details

#changeObject



4
5
6
7
# File 'lib/ver/text/range.rb', line 4

def change
  kill
  buffer.minor_mode(:control, :insert)
end

#copyObject



9
10
11
# File 'lib/ver/text/range.rb', line 9

def copy
  buffer.with_register{|reg| reg.value = get }
end

#count(*options) ⇒ Object



13
14
15
# File 'lib/ver/text/range.rb', line 13

def count(*options)
  buffer.count(*self, *options)
end

#delete(*indices) ⇒ Object



17
18
19
# File 'lib/ver/text/range.rb', line 17

def delete(*indices)
  buffer.delete(*self, *indices)
end

#dump(*options) ⇒ Object



21
22
23
# File 'lib/ver/text/range.rb', line 21

def dump(*options)
  buffer.dump(*options, *self)
end

#encode_rot13!(record = buffer) ⇒ Object



25
26
27
# File 'lib/ver/text/range.rb', line 25

def encode_rot13!(record = buffer)
  record.replace(*self, get.tr('A-Ma-mN-Zn-z', 'N-Zn-zA-Ma-m'))
end

#getObject



33
34
35
# File 'lib/ver/text/range.rb', line 33

def get
  buffer.get(*self)
end

#inspectObject



37
38
39
# File 'lib/ver/text/range.rb', line 37

def inspect
  "#<VER::Text::Range %s on %p>" % ["(#{first}..#{last})", buffer]
end

#killObject



41
42
43
44
# File 'lib/ver/text/range.rb', line 41

def kill
  copy
  delete
end

#lower_case!(record = buffer) ⇒ Object Also known as: downcase!



50
51
52
# File 'lib/ver/text/range.rb', line 50

def lower_case!(record = buffer)
  record.replace(*self, get.downcase)
end

#replace(*args) ⇒ Object



55
56
57
# File 'lib/ver/text/range.rb', line 55

def replace(*args)
  buffer.replace(first, last, *args)
end

#to_aObject



59
60
61
# File 'lib/ver/text/range.rb', line 59

def to_a
  [first, last]
end

#toggle_case!(record = buffer) ⇒ Object



63
64
65
# File 'lib/ver/text/range.rb', line 63

def toggle_case!(record = buffer)
  record.replace(*self, get.tr('a-zA-Z', 'A-Za-z'))
end

#upper_case!(record = buffer) ⇒ Object Also known as: upcase!

alias needed?



68
69
70
# File 'lib/ver/text/range.rb', line 68

def upper_case!(record = buffer)
  record.replace(*self, get.upcase)
end