Class: LWAC::ServerState

Inherits:
Object
  • Object
show all
Defined in:
lib/lwac/shared/data_types.rb

Overview


Holds time-dependent parameters of the server, meaning:

* The last sample that was completed, and its duration
* The current sample in progress
* The time when the next sample is due

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version, last_sample_id = -1,, current_sample = nil, next_sample_due = nil) ⇒ ServerState

Returns a new instance of ServerState.



274
275
276
277
278
279
280
# File 'lib/lwac/shared/data_types.rb', line 274

def initialize(version, last_sample_id=-1, current_sample=nil, next_sample_due=nil)
  @version                    = version
  @last_sample_id             = last_sample_id
  @current_sample             = current_sample        || Sample.new(-1, 0)
  @next_sample_due            = next_sample_due       || Time.now
  @last_sample_duration       = last_sample_duration  || 1
end

Instance Attribute Details

#current_sampleObject

Returns the value of attribute current_sample.



271
272
273
# File 'lib/lwac/shared/data_types.rb', line 271

def current_sample
  @current_sample
end

#last_sample_durationObject

Returns the value of attribute last_sample_duration.



271
272
273
# File 'lib/lwac/shared/data_types.rb', line 271

def last_sample_duration
  @last_sample_duration
end

#last_sample_idObject

Returns the value of attribute last_sample_id.



271
272
273
# File 'lib/lwac/shared/data_types.rb', line 271

def last_sample_id
  @last_sample_id
end

#next_sample_dueObject

Returns the value of attribute next_sample_due.



271
272
273
# File 'lib/lwac/shared/data_types.rb', line 271

def next_sample_due
  @next_sample_due
end

#versionObject (readonly)

Returns the value of attribute version.



272
273
274
# File 'lib/lwac/shared/data_types.rb', line 272

def version
  @version
end