class StringJoiner
does not override String#concat nor String#+
Constants
- VERSION
Public Class Methods
new(str = "", separator = ", ", allow_blanks: false, allow_leading_separator: false)
click to toggle source
Calls superclass method
# File lib/string_joiner.rb, line 16 def initialize(str = "", separator = ", ", allow_blanks: false, allow_leading_separator: false) str, separator = str.to_s, separator.to_s # liberal, allow symbols str = "" if !allow_blanks && str.blank? super(str) @separator = separator @allow_blanks = allow_blanks @allow_leading_separator = allow_leading_separator end
Public Instance Methods
<<(str)
click to toggle source
Calls superclass method
# File lib/string_joiner.rb, line 25 def <<(str) str = str.to_s # liberal, allow symbols return self if !@allow_blanks && str.blank? # don't add blanks if not allowed return replace(str) if !@allow_leading_separator && self == "" # don't allow leading comma nor replace with blank if not allowed super(@separator + str) end
to_s()
click to toggle source
# File lib/string_joiner.rb, line 34 def to_s String.new(self) end