Class: SlackProgress::MessageBuilder
- Inherits:
-
Object
- Object
- SlackProgress::MessageBuilder
- Defined in:
- lib/slack-progress/message_builder.rb
Instance Method Summary collapse
- #build_message(current_value, max_value) ⇒ Object
-
#initialize(formatting_options) ⇒ MessageBuilder
constructor
A new instance of MessageBuilder.
Constructor Details
#initialize(formatting_options) ⇒ MessageBuilder
Returns a new instance of MessageBuilder.
4 5 6 |
# File 'lib/slack-progress/message_builder.rb', line 4 def initialize() = end |
Instance Method Details
#build_message(current_value, max_value) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/slack-progress/message_builder.rb', line 8 def (current_value, max_value) return if current_value > max_value return if current_value < 0 || max_value < 0 num_boxes = 10 ratio = current_value.to_f / max_value.to_f percentage = (ratio * 100).round(1) fill_count = (percentage / num_boxes).round remaining_count = num_boxes - fill_count = .title += "\n" += (.completed_filler) * fill_count += (.remaining_filler) * remaining_count += " #{current_value} / #{max_value}" += " (#{percentage} %) finished." end |