Class: SeeingIsBelieving::Binary::CommentFormatter
- Inherits:
-
Object
- Object
- SeeingIsBelieving::Binary::CommentFormatter
- Defined in:
- lib/seeing_is_believing/binary/comment_formatter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(line_length, separator, result, options) ⇒ CommentFormatter
constructor
A new instance of CommentFormatter.
Constructor Details
#initialize(line_length, separator, result, options) ⇒ CommentFormatter
Returns a new instance of CommentFormatter.
8 9 10 11 12 13 |
# File 'lib/seeing_is_believing/binary/comment_formatter.rb', line 8 def initialize(line_length, separator, result, ) self.line_length = line_length self.separator = separator self.result = result.gsub "\n", '\n' self. = end |
Class Method Details
.call(*args) ⇒ Object
4 5 6 |
# File 'lib/seeing_is_believing/binary/comment_formatter.rb', line 4 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/seeing_is_believing/binary/comment_formatter.rb', line 15 def call @formatted ||= begin formatted = truncate "#{separator}#{result}", max_result_length formatted = "#{' '*padding_length}#{formatted}" formatted = truncate formatted, max_line_length formatted = '' unless formatted.sub(/^ */, '').start_with? separator formatted end end |