Class: Vizir::Job

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, end_time, site_name) ⇒ Job

Returns a new instance of Job.



115
116
117
118
119
# File 'lib/vizir.rb', line 115

def initialize(id, end_time, site_name)
  @id = id
  @end_time = end_time
  @site_name = site_name
end

Instance Attribute Details

#end_timeObject (readonly)

Returns the value of attribute end_time.



113
114
115
# File 'lib/vizir.rb', line 113

def end_time
  @end_time
end

#idObject (readonly)

Returns the value of attribute id.



113
114
115
# File 'lib/vizir.rb', line 113

def id
  @id
end

#site_nameObject (readonly)

Returns the value of attribute site_name.



113
114
115
# File 'lib/vizir.rb', line 113

def site_name
  @site_name
end

Class Method Details

.create_from_json(json, site_name) ⇒ Object



121
122
123
# File 'lib/vizir.rb', line 121

def Job.create_from_json(json, site_name)
  return Job.new(json['Job_Id'], Time.at(Integer(json['startTime']) + Integer(json['walltime'])), site_name.capitalize)
end

Instance Method Details

#fetch_details(api) ⇒ Object



125
126
127
# File 'lib/vizir.rb', line 125

def fetch_details(api)
  return Vizir.get(api, "/sites/#{@site_name.downcase}/jobs/#{@id}")
end

#is_ended?(api) ⇒ Boolean

Returns:

  • (Boolean)


133
134
135
136
# File 'lib/vizir.rb', line 133

def is_ended?(api)
  updatedjob = self.fetch_details(api)
  return updatedjob['state'] != 'Running'
end

#should_be_ending?(time = Time.now()) ⇒ Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/vizir.rb', line 129

def should_be_ending?(time=Time.now())
  return Vizir.get_remaining_time(self.end_time, time) <= Vizir::FIRST_ALERT_TIME
end