Class: Rukawa::AbstractJob
- Inherits:
-
Object
- Object
- Rukawa::AbstractJob
- Extended by:
- ActiveSupport::DescendantsTracker
- Defined in:
- lib/rukawa/abstract_job.rb
Instance Attribute Summary collapse
-
#parent_job_net ⇒ Object
readonly
Returns the value of attribute parent_job_net.
Class Method Summary collapse
- .add_skip_rule(callable_or_symbol) ⇒ Object
- .description ⇒ Object (also: desc)
- .set_description(body) ⇒ Object (also: set_desc)
Instance Method Summary collapse
- #elapsed_time_from(time = Time.now) ⇒ Object
- #formatted_elapsed_time_from(time = Time.now) ⇒ Object
- #inspect ⇒ Object
- #name ⇒ Object
- #skip? ⇒ Boolean
Instance Attribute Details
#parent_job_net ⇒ Object (readonly)
Returns the value of attribute parent_job_net.
7 8 9 |
# File 'lib/rukawa/abstract_job.rb', line 7 def parent_job_net @parent_job_net end |
Class Method Details
.add_skip_rule(callable_or_symbol) ⇒ Object
13 14 15 |
# File 'lib/rukawa/abstract_job.rb', line 13 def add_skip_rule(callable_or_symbol) self.skip_rules = skip_rules + [callable_or_symbol] end |
.description ⇒ Object Also known as: desc
17 18 19 |
# File 'lib/rukawa/abstract_job.rb', line 17 def description @description end |
.set_description(body) ⇒ Object Also known as: set_desc
22 23 24 |
# File 'lib/rukawa/abstract_job.rb', line 22 def set_description(body) @description = body end |
Instance Method Details
#elapsed_time_from(time = Time.now) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/rukawa/abstract_job.rb', line 43 def elapsed_time_from(time = Time.now) return finished_at - started_at if started_at && finished_at return time - started_at if started_at nil end |
#formatted_elapsed_time_from(time = Time.now) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rukawa/abstract_job.rb', line 50 def formatted_elapsed_time_from(time = Time.now) elapsed = elapsed_time_from(time) return "N/A" unless elapsed hour = elapsed.to_i / 3600 min = (elapsed - hour * 3600).to_i / 60 sec = (elapsed - hour * 3600 - min * 60).to_i hour_format = hour > 0 ? "%dh " % hour : "" min_format = hour > 0 || min > 0 ? "%dm " % min : "" sec_format = "#{sec}s" "#{hour_format}#{min_format}#{sec_format}" end |
#inspect ⇒ Object
32 33 34 |
# File 'lib/rukawa/abstract_job.rb', line 32 def inspect to_s end |
#name ⇒ Object
28 29 30 |
# File 'lib/rukawa/abstract_job.rb', line 28 def name self.class.name || self.class.to_s end |
#skip? ⇒ Boolean
36 37 38 39 40 41 |
# File 'lib/rukawa/abstract_job.rb', line 36 def skip? parent_skip = @parent_job_net ? @parent_job_net.skip? : false parent_skip || skip_rules.inject(false) do |cond, rule| cond || rule.is_a?(Symbol) ? method(rule).call : rule.call(self) end end |