Class: Applitools::BatchInfo

Inherits:
Object
  • Object
show all
Extended by:
Helpers
Defined in:
lib/applitools/core/batch_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

abstract_attr_accessor, abstract_method, env_variable, environment_attribute, environment_variables

Constructor Details

#initialize(args = nil, started_at = Time.now) ⇒ BatchInfo

Returns a new instance of BatchInfo.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/applitools/core/batch_info.rb', line 18

def initialize(args = nil, started_at = Time.now)
  case args
    when String
      name = args
    when Hash
      sym_args = Applitools::Utils.symbolize_keys args
      id ||= sym_args[:id]
      name ||= sym_args[:name]
      properties ||= sym_args[:properties]
  end
  self.name = name if name
  @started_at = started_at
  if id
    self.id = id
  elsif self.id.nil? || self.id.empty?
    self.id = SecureRandom.uuid
  end
  self.properties = properties if properties
  self.notify_on_completion = 'true'.casecmp(env_notify_on_completion || '') == 0 ? true : false
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/applitools/core/batch_info.rb', line 10

def id
  @id
end

#notify_on_completionObject

Returns the value of attribute notify_on_completion.



10
11
12
# File 'lib/applitools/core/batch_info.rb', line 10

def notify_on_completion
  @notify_on_completion
end

#propertiesObject

Returns the value of attribute properties.



10
11
12
# File 'lib/applitools/core/batch_info.rb', line 10

def properties
  @properties
end

#started_atObject

Returns the value of attribute started_at.



10
11
12
# File 'lib/applitools/core/batch_info.rb', line 10

def started_at
  @started_at
end

Instance Method Details

#json_dataObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/applitools/core/batch_info.rb', line 39

def json_data
  {
      'id' => id,
      'name' => name,
      'startedAt' => @started_at.iso8601,
      'batchSequenceName' => sequence_name,
      'notifyOnCompletion' => notify_on_completion,
      'properties' => properties
  }
end

#to_hashObject



50
51
52
# File 'lib/applitools/core/batch_info.rb', line 50

def to_hash
  json_data
end

#to_sObject



54
55
56
# File 'lib/applitools/core/batch_info.rb', line 54

def to_s
  to_hash.to_s
end