Sha256: ab3508e60419546c969012bbbfc12399a18184c018b13d4494e0465421d07556

Contents?: true

Size: 596 Bytes

Versions: 3

Compression:

Stored size: 596 Bytes

Contents

class ::String
  def parentheses
    "(#{self})"
  end

  def braces
    "{#{self}}"
  end

  def rm(str_or_rgx)
    gsub(str_or_rgx, '')
  end

  def rm!(str_or_rgx)
    gsub!(str_or_rgx, '')
    self
  end

  def rms!(*str_or_rgxs)
    str_or_rgxs.each do |str_or_rgx|
      rm!(str_or_rgx)
    end
    self
  end

  def split_by_sp
    split(/ +/)
  end

  # FIX:
  def equalize!
    rms!(/\A +/, / +\z/)
    if self =~ /\A\(/ && self =~ /\)\z/
      rms!(/\A\(/, /\)\z/)
      rms!(/\A +/, / +\z/)
    else
      self
    end
  end
end

class ::Array
  def join_by_sp
    join(' ')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qlang-0.0.27182110 lib/qlang/utils/ruby_ext.rb
qlang-0.0.27182100 lib/qlang/utils/ruby_ext.rb
qlang-0.0.27182000 lib/qlang/utils/ruby_ext.rb