Class: Px4LogReader::Progress

Inherits:
Object
  • Object
show all
Defined in:
lib/px4_log_reader/progress.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(active_file) ⇒ Progress

Returns a new instance of Progress.



39
40
41
42
43
44
45
# File 'lib/px4_log_reader/progress.rb', line 39

def initialize( active_file )
  @active_file = active_file

  active_file.seek( 0, IO::SEEK_END )
  @file_size = active_file.pos
  active_file.seek( 0 )
end

Instance Attribute Details

#file_sizeObject

Returns the value of attribute file_size.



37
38
39
# File 'lib/px4_log_reader/progress.rb', line 37

def file_size
  @file_size
end

Instance Method Details

#file_offsetObject



47
48
49
# File 'lib/px4_log_reader/progress.rb', line 47

def file_offset
  @active_file.pos
end

#percentageObject



51
52
53
# File 'lib/px4_log_reader/progress.rb', line 51

def percentage
  return ( file_offset.to_f / @file_size.to_f )
end