Class: PVN::TextLines

Inherits:
Object
  • Object
show all
Includes:
Logue::Loggable
Defined in:
lib/pvn/util/textlines.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lines) ⇒ TextLines

Returns a new instance of TextLines.



13
14
15
16
# File 'lib/pvn/util/textlines.rb', line 13

def initialize lines
  @lines = lines
  @lidx = 0
end

Instance Attribute Details

#linesObject (readonly)

Returns the value of attribute lines.



11
12
13
# File 'lib/pvn/util/textlines.rb', line 11

def lines
  @lines
end

Instance Method Details

#advance_line(offset = 1) ⇒ Object



30
31
32
# File 'lib/pvn/util/textlines.rb', line 30

def advance_line offset = 1
  @lidx += offset
end

#has_line?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/pvn/util/textlines.rb', line 26

def has_line?
  @lidx < @lines.length
end

#line(offset = 0) ⇒ Object



22
23
24
# File 'lib/pvn/util/textlines.rb', line 22

def line offset = 0
  @lines[@lidx + offset]
end

#match_line(re, offset = 0) ⇒ Object



18
19
20
# File 'lib/pvn/util/textlines.rb', line 18

def match_line re, offset = 0
  re.match line(offset)
end