module Embrace

Constants

BRACES
BRACKETS
DOUBLE_QUOTES
PARENTHESES
SINGLE_QUOTES
VERSION

Public Instance Methods

Brackets(style_or_opening, *closing) click to toggle source
# File lib/embrace/brackets.rb, line 19
def Brackets(style_or_opening, *closing)
  return Brackets.from_brackets(style_or_opening, *closing) unless closing.empty?

  case style_or_opening
  when Proc  then style_or_opening
  when Array then Brackets.from_brackets(*style_or_opening)
  else
    Brackets.from_str(style_or_opening.to_s)
  end
end
bracket(text, style:, pattern: /\A.*\z/) click to toggle source
# File lib/embrace.rb, line 19
def bracket(text, style:, pattern: /\A.*\z/)
  text.gsub(pattern, &Brackets(style))
end
bracketer(style:, **options) click to toggle source
# File lib/embrace.rb, line 23
def bracketer(style:, **options)
  brackets = Brackets(style)
  ->(text) { bracket(text, style: brackets, **options)}
end