Class: SeeingIsBelieving::Binary::AlignFile
- Inherits:
-
Object
- Object
- SeeingIsBelieving::Binary::AlignFile
- Defined in:
- lib/seeing_is_believing/binary/align_file.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
Instance Method Summary collapse
-
#initialize(body) ⇒ AlignFile
constructor
A new instance of AlignFile.
-
#line_length_for(line_number) ⇒ Object
max line length of the lines to output (exempting comments) + 2 spaces for padding.
Constructor Details
#initialize(body) ⇒ AlignFile
Returns a new instance of AlignFile.
8 9 10 |
# File 'lib/seeing_is_believing/binary/align_file.rb', line 8 def initialize(body) self.body = body end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
6 7 8 |
# File 'lib/seeing_is_believing/binary/align_file.rb', line 6 def body @body end |
Instance Method Details
#line_length_for(line_number) ⇒ Object
max line length of the lines to output (exempting comments) + 2 spaces for padding
13 14 15 16 17 18 19 20 21 |
# File 'lib/seeing_is_believing/binary/align_file.rb', line 13 def line_length_for(line_number) @max_source_line_length ||= 2 + begin line_num_to_indexes = CommentableLines.new(body).call # {line_number => [index_in_file, index_in_col]} max_value = line_num_to_indexes .values .map { |index, col| col }.max max_value || 0 end end |