Class: MilkMaid::BatchRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/milk_maid/google_sheet_notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(batch_data = {}) ⇒ BatchRecord

Returns a new instance of BatchRecord.



36
37
38
39
# File 'lib/milk_maid/google_sheet_notifier.rb', line 36

def initialize(batch_data = {})
  batch_data.each { |key, value| send("#{key}=", value) }
  @status = 'Started'
end

Instance Attribute Details

#base_temperatureObject

Returns the value of attribute base_temperature.



34
35
36
# File 'lib/milk_maid/google_sheet_notifier.rb', line 34

def base_temperature
  @base_temperature
end

#batch_sizeObject

Returns the value of attribute batch_size.



34
35
36
# File 'lib/milk_maid/google_sheet_notifier.rb', line 34

def batch_size
  @batch_size
end

#durationObject

Returns the value of attribute duration.



34
35
36
# File 'lib/milk_maid/google_sheet_notifier.rb', line 34

def duration
  @duration
end

#guidObject

Returns the value of attribute guid.



34
35
36
# File 'lib/milk_maid/google_sheet_notifier.rb', line 34

def guid
  @guid
end

#nameObject

Returns the value of attribute name.



34
35
36
# File 'lib/milk_maid/google_sheet_notifier.rb', line 34

def name
  @name
end

#recordObject

Returns the value of attribute record.



34
35
36
# File 'lib/milk_maid/google_sheet_notifier.rb', line 34

def record
  @record
end

#statusObject

Returns the value of attribute status.



34
35
36
# File 'lib/milk_maid/google_sheet_notifier.rb', line 34

def status
  @status
end

Instance Method Details

#add_event(event_type, data = 0) ⇒ Object



41
42
43
# File 'lib/milk_maid/google_sheet_notifier.rb', line 41

def add_event(event_type, data = 0)
  events << ::MilkMaid::Event.new(event_name_from_type(event_type), data, timestamp)
end

#complete!Object



45
46
47
48
# File 'lib/milk_maid/google_sheet_notifier.rb', line 45

def complete!
  add_event(:batch_completed)
  @status = 'Completed'
end

#event_name_from_type(event) ⇒ Object



50
51
52
# File 'lib/milk_maid/google_sheet_notifier.rb', line 50

def event_name_from_type(event)
  event.to_s.split(/_/).map(&:capitalize).join(' ')
end

#eventsObject



54
55
56
# File 'lib/milk_maid/google_sheet_notifier.rb', line 54

def events
  @events ||= []
end

#timestampObject



58
59
60
# File 'lib/milk_maid/google_sheet_notifier.rb', line 58

def timestamp
  Time.now
end