Class: Vizir::Job
- Inherits:
-
Object
- Object
- Vizir::Job
- Defined in:
- lib/vizir.rb
Instance Attribute Summary collapse
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#site_name ⇒ Object
readonly
Returns the value of attribute site_name.
Class Method Summary collapse
Instance Method Summary collapse
- #fetch_details(api) ⇒ Object
-
#initialize(id, end_time, site_name) ⇒ Job
constructor
A new instance of Job.
- #is_ended?(api) ⇒ Boolean
- #should_be_ending?(time = Time.now()) ⇒ Boolean
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_time ⇒ Object (readonly)
Returns the value of attribute end_time.
113 114 115 |
# File 'lib/vizir.rb', line 113 def end_time @end_time end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
113 114 115 |
# File 'lib/vizir.rb', line 113 def id @id end |
#site_name ⇒ Object (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
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
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
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 |