class DTK::Client::Operation::Service::TaskStatus::StreamMode::Element::Format
Constants
- Settings
Public Class Methods
new(type)
click to toggle source
Calls superclass method
# File lib/client/operation/service/task_status/stream_mode/element/format.rb, line 44 def initialize(type) super() @type = type && type.to_sym replace(Settings[:default].merge(Settings[@type] || {})) end
Public Instance Methods
border()
click to toggle source
# File lib/client/operation/service/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)
click to toggle source
# File lib/client/operation/service/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 = {})
click to toggle source
# File lib/client/operation/service/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)
click to toggle source
# File lib/client/operation/service/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)
click to toggle source
# File lib/client/operation/service/task_status/stream_mode/element/format.rb, line 61 def start_time_msg?(started_at) if started_at "TIME START: #{started_at}" end end
Private Instance Methods
augment(msg, params = {})
click to toggle source
# File lib/client/operation/service/task_status/stream_mode/element/format.rb, line 87 def augment(msg, params = {}) msg_prefix = '' started_at = params[:started_at] if started_at and self[:include_start_time] msg_prefix << "#{started_at} " end ret = "#{msg_prefix}#{msg}" if tabs = params[:tabs] ident = ' ' * (tabs * self[:tab_size]) ret = ret.split("\n").map { |line| "#{ident}#{line}" }.join("\n") end ret end
bracket(aug_msg)
click to toggle source
# File lib/client/operation/service/task_status/stream_mode/element/format.rb, line 81 def bracket(aug_msg) bracket_symbol = self[:bracket_symbol] bracket_size = self[:bracket_size] "#{bracket_symbol * bracket_size} #{aug_msg} #{bracket_symbol * bracket_size}" end