Class: ExtremeFeedbackDevice::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/extreme_feedback_device/job.rb

Constant Summary collapse

COLOR_RED =
/\Ared/
COLOR_YELLOW =
/\Ayellow/
COLOR_BLUE =
/\Ablue/
COLOR_GREY =
/\Agrey/
COLOR_DISABLED =
/\Adisabled/
COLOR_ABORTED =
/\Aaborted/
COLOR_NOTBUILT =
/\Anotbuilt/

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_json_object(attributes) ⇒ Object



13
14
15
16
17
# File 'lib/extreme_feedback_device/job.rb', line 13

def from_json_object(attributes)
  health_report = attributes['healthReport']
  attributes['score'] = health_report.first.nil? ? nil : health_report.first['score']
  new(attributes['name'], attributes['color'], attributes['score'])
end

Instance Method Details

#aborted?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/extreme_feedback_device/job.rb', line 44

def aborted?
  color && color =~ COLOR_ABORTED
end

#disabled?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/extreme_feedback_device/job.rb', line 40

def disabled?
  color && color =~ COLOR_DISABLED
end

#fail?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/extreme_feedback_device/job.rb', line 24

def fail?
  color && color =~ COLOR_RED
end

#inactive?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/extreme_feedback_device/job.rb', line 36

def inactive?
  color && color =~ COLOR_GREY
end

#not_built?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/extreme_feedback_device/job.rb', line 48

def not_built?
  color && color =~ COLOR_NOTBUILT
end

#success?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/extreme_feedback_device/job.rb', line 32

def success?
  color && color =~ COLOR_BLUE
end

#to_hashObject



20
21
22
# File 'lib/extreme_feedback_device/job.rb', line 20

def to_hash
  {name: name, color: color, health: health}
end

#unstable?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/extreme_feedback_device/job.rb', line 28

def unstable?
  color && color =~ COLOR_YELLOW
end