Class: Wp2txt::CmdProgbar

Inherits:
Object
  • Object
show all
Defined in:
lib/wp2txt/progressbar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCmdProgbar

Returns a new instance of CmdProgbar.



264
265
266
267
# File 'lib/wp2txt/progressbar.rb', line 264

def initialize
  @last_value = 0
  @pbar = nil
end

Instance Attribute Details

#last_valueObject

Returns the value of attribute last_value.



262
263
264
# File 'lib/wp2txt/progressbar.rb', line 262

def last_value
  @last_value
end

#pbarObject

Returns the value of attribute pbar.



262
263
264
# File 'lib/wp2txt/progressbar.rb', line 262

def pbar
  @pbar
end

Instance Method Details

#afterObject



299
300
301
302
# File 'lib/wp2txt/progressbar.rb', line 299

def after
  @pbar.finish 
  return true
end

#beforeObject



295
296
297
# File 'lib/wp2txt/progressbar.rb', line 295

def before
  initialize
end

#data_set(filename, linesize) ⇒ Object



286
287
288
# File 'lib/wp2txt/progressbar.rb', line 286

def data_set(filename, linesize)
  @pbar = NewProgressBar.new(filename, linesize)
end

#data_update(nhits, nsentences) ⇒ Object



290
291
292
293
# File 'lib/wp2txt/progressbar.rb', line 290

def data_update(nhits, nsentences)
  @pbar.nhits = nhits
  @pbar.nsentences = nsentences
end

#msg(str, i = nil) ⇒ Object



269
270
271
272
273
274
275
276
# File 'lib/wp2txt/progressbar.rb', line 269

def msg(str, i = nil)
  case i
  when 0
    print str
  else
    puts str
  end
end

#prg_update(value, elt, eta) ⇒ Object



278
279
280
281
282
283
284
# File 'lib/wp2txt/progressbar.rb', line 278

def prg_update(value, elt, eta)
  @elt = elt
  @eta = eta
  offset = value - @last_value
  @pbar.inc(offset.to_i)
  @last_value = value
end