Class: SeeingIsBelieving::Binary::LineFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/seeing_is_believing/binary/line_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line, separator, result, options) ⇒ LineFormatter

Returns a new instance of LineFormatter.



6
7
8
9
10
11
# File 'lib/seeing_is_believing/binary/line_formatter.rb', line 6

def initialize(line, separator, result, options)
 self.line      = line
 self.separator = separator
 self.result    = result.gsub "\n", '\n'
 self.options   = options
end

Instance Attribute Details

#lineObject

Returns the value of attribute line.



4
5
6
# File 'lib/seeing_is_believing/binary/line_formatter.rb', line 4

def line
  @line
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/seeing_is_believing/binary/line_formatter.rb', line 4

def options
  @options
end

#resultObject

Returns the value of attribute result.



4
5
6
# File 'lib/seeing_is_believing/binary/line_formatter.rb', line 4

def result
  @result
end

#separatorObject

Returns the value of attribute separator.



4
5
6
# File 'lib/seeing_is_believing/binary/line_formatter.rb', line 4

def separator
  @separator
end

Instance Method Details

#callObject



13
14
15
16
17
# File 'lib/seeing_is_believing/binary/line_formatter.rb', line 13

def call
  return line unless sep_plus_result.start_with? separator
  return line unless formatted_line.start_with? "#{line_with_padding}#{separator}"
  formatted_line
end