Class: Px4LogReader::Progress
- Inherits:
-
Object
- Object
- Px4LogReader::Progress
- Defined in:
- lib/px4_log_reader/progress.rb
Instance Attribute Summary collapse
-
#file_size ⇒ Object
Returns the value of attribute file_size.
Instance Method Summary collapse
- #file_offset ⇒ Object
-
#initialize(active_file) ⇒ Progress
constructor
A new instance of Progress.
- #percentage ⇒ Object
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_size ⇒ Object
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_offset ⇒ Object
47 48 49 |
# File 'lib/px4_log_reader/progress.rb', line 47 def file_offset @active_file.pos end |
#percentage ⇒ Object
51 52 53 |
# File 'lib/px4_log_reader/progress.rb', line 51 def percentage return ( file_offset.to_f / @file_size.to_f ) end |