Class: DTK::Client::TaskStatus::StreamMode::Element::Format
- Inherits:
-
Hash
- Object
- Hash
- DTK::Client::TaskStatus::StreamMode::Element::Format
- Defined in:
- lib/task_status/stream_mode/element/format.rb
Constant Summary collapse
- Settings =
{ :task_start => { }, :task_end => { }, :stage => { }, :stage_start => { :border_symbol => '=', }, :stage_end => { :border_symbol => '-', }, :default => { :border_symbol => '=', :border_size => 60, :bracket_symbol => '=', :bracket_size => 25, :duration_accuracy => 1, # how many decimal places accuracy :include_start_time => true, :tab_size => 2, # how many spaces each tab has } }
Instance Method Summary collapse
- #border ⇒ Object
- #duration_msg?(duration) ⇒ Boolean
- #format(msg, params = {}) ⇒ Object
- #formatted_duration?(duration) ⇒ Boolean
-
#initialize(type) ⇒ Format
constructor
A new instance of Format.
- #start_time_msg?(started_at) ⇒ Boolean
Constructor Details
Instance Method Details
#border ⇒ Object
55 56 57 58 59 |
# File 'lib/task_status/stream_mode/element/format.rb', line 55 def border border_symbol = self[:border_symbol] border_size = self[:border_size] "#{border_symbol * border_size}" end |
#duration_msg?(duration) ⇒ Boolean
73 74 75 76 77 |
# File 'lib/task_status/stream_mode/element/format.rb', line 73 def duration_msg?(duration) if formatted_duration = formatted_duration?(duration) "DURATION: #{formatted_duration}" end end |
#format(msg, params = {}) ⇒ Object
50 51 52 53 |
# File 'lib/task_status/stream_mode/element/format.rb', line 50 def format(msg, params = {}) aug_msg = augment(msg, params) params[:bracket] ? bracket(aug_msg) : aug_msg end |
#formatted_duration?(duration) ⇒ Boolean
67 68 69 70 71 |
# File 'lib/task_status/stream_mode/element/format.rb', line 67 def formatted_duration?(duration) if duration "#{duration.round(self[:duration_accuracy])}s" end end |
#start_time_msg?(started_at) ⇒ Boolean
61 62 63 64 65 |
# File 'lib/task_status/stream_mode/element/format.rb', line 61 def start_time_msg?(started_at) if started_at "TIME START: #{started_at}" end end |