Class: Fuzz::FileObject::LinePointer

Inherits:
Object
  • Object
show all
Defined in:
lib/fuzz/fzzr.rb

Constant Summary collapse

FZZR_ENABLE_RE =
/X11_FUZZ\: enable ([^\s]+)/
FZZR_DISABLE_RE =
/X11_FUZZ\: disable ([^\s]+)/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lines, fzzr_id) ⇒ LinePointer

Returns a new instance of LinePointer.



134
135
136
137
138
139
# File 'lib/fuzz/fzzr.rb', line 134

def initialize(lines, fzzr_id)
  @lines = lines
  @fzzr_id = fzzr_id.to_s
  @err_lines = []
  reset
end

Instance Attribute Details

#err_linesObject (readonly)

Returns the value of attribute err_lines.



129
130
131
# File 'lib/fuzz/fzzr.rb', line 129

def err_lines
  @err_lines
end

Instance Method Details

#bof?Boolean

Returns:

  • (Boolean)


185
186
187
# File 'lib/fuzz/fzzr.rb', line 185

def bof?
  @line_nr <= 0
end

#eof?Boolean

Returns:

  • (Boolean)


182
183
184
# File 'lib/fuzz/fzzr.rb', line 182

def eof?
  @line_nr >= @lines.size
end

#fzzr_disabled?Boolean

Returns:

  • (Boolean)


140
141
142
# File 'lib/fuzz/fzzr.rb', line 140

def fzzr_disabled?
  @fzzr_disabled
end

#line_nrObject



143
144
145
# File 'lib/fuzz/fzzr.rb', line 143

def line_nr
  @line_nr+1
end

#mark_error(ln = nil) ⇒ Object



188
189
190
# File 'lib/fuzz/fzzr.rb', line 188

def mark_error(ln = nil)
  @err_lines << (ln || (@line_nr+1))
end

#move(offs) ⇒ Object



166
167
168
169
170
171
172
173
# File 'lib/fuzz/fzzr.rb', line 166

def move(offs)
  if offs < 0
    _backward(-offs) unless bof?
  else
    _forward(offs) unless eof?
  end
  self.line_nr
end

#resetObject



174
175
176
177
178
# File 'lib/fuzz/fzzr.rb', line 174

def reset
  @line_nr = 0
  @fzzr_disabled = false
  _check_fzzr_escape
end

#set_text_at(offs, txt) ⇒ Object



153
154
155
156
157
158
159
# File 'lib/fuzz/fzzr.rb', line 153

def set_text_at(offs, txt)
  ln = @line_nr+offs
  if ln>=0 && ln<@lines.size
    return (@lines[ln] = txt)
  end
  nil
end

#textObject



160
161
162
# File 'lib/fuzz/fzzr.rb', line 160

def text
  text_at(0)
end

#text=(txt) ⇒ Object



163
164
165
# File 'lib/fuzz/fzzr.rb', line 163

def text=(txt)
  set_text_at(0, txt)
end

#text_at(offs) ⇒ Object



146
147
148
149
150
151
152
# File 'lib/fuzz/fzzr.rb', line 146

def text_at(offs)
  ln = @line_nr+offs
  if ln>=0 && ln<@lines.size
    return @lines[ln]
  end
  nil
end

#to_eofObject



179
180
181
# File 'lib/fuzz/fzzr.rb', line 179

def to_eof
  _forward(@lines.size - @line_nr)
end