Class: Omnizip::ETA::SampleHistory::Sample

Inherits:
Struct
  • Object
show all
Defined in:
lib/omnizip/eta/sample_history.rb

Overview

Single sample data point

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bytes_processedObject

Returns the value of attribute bytes_processed

Returns:

  • (Object)

    the current value of bytes_processed



16
17
18
# File 'lib/omnizip/eta/sample_history.rb', line 16

def bytes_processed
  @bytes_processed
end

#files_processedObject

Returns the value of attribute files_processed

Returns:

  • (Object)

    the current value of files_processed



16
17
18
# File 'lib/omnizip/eta/sample_history.rb', line 16

def files_processed
  @files_processed
end

#timestampObject

Returns the value of attribute timestamp

Returns:

  • (Object)

    the current value of timestamp



16
17
18
# File 'lib/omnizip/eta/sample_history.rb', line 16

def timestamp
  @timestamp
end

Instance Method Details

#rate_since(other) ⇒ Float

Calculate bytes/second rate between two samples

Parameters:

  • other (Sample)

    Earlier sample

Returns:

  • (Float)

    Bytes per second



21
22
23
24
25
26
27
# File 'lib/omnizip/eta/sample_history.rb', line 21

def rate_since(other)
  time_diff = timestamp - other.timestamp
  return 0.0 if time_diff <= 0

  bytes_diff = bytes_processed - other.bytes_processed
  bytes_diff / time_diff
end