module SuperSub

Constants

CIRCLED
CIRCLED_NEGATIVE
DOUBLE_STRUCK
FAUX_CYRILLIC
FULLWIDTH
GOTHIC
GOTHIC_BOLD
INVERTED
MONOSPACE
REVERSED
SANS
SANS_BOLD
SANS_BOLD_ITALIC
SANS_ITALIC
SCRIPT
SCRIPT_BOLD
SERIF_BOLD
SMALL_CAPS
SQUARED
SQUARED_NEGATIVE
SUBSCRIPT
SUPERSCRIPT

Public Class Methods

convert(str, style) click to toggle source
# File lib/supersub.rb, line 1447
def self.convert(str, style)
  case style
  when :superscript, :super
    convert_text(str, SUPERSCRIPT)
  when :subscript, :sub
    convert_text(str, SUBSCRIPT)
  when :script
    convert_text(str, SCRIPT)
  when :script_bold, :bold_script
    convert_text(str, SCRIPT_BOLD)
  when :fullwidth, :full_width
    convert_text(str, FULLWIDTH)
  when :monospace, :typewriter
    convert_text(str, MONOSPACE)
  when :gothic, :fraktur
    convert_text(str, GOTHIC)
  when :gothic_bold, :bold_gothic, :fraktur_bold
    convert_text(str, GOTHIC_BOLD)
  when :sans, :math_sans
    convert_text(str, SANS)
  when :sans_italic, :italic_sans
    convert_text(str, SANS_ITALIC)
  when :sans_bold, :bold_sans
    convert_text(str, SANS_BOLD)
  when :sans_bold_italic
    convert_text(str, SANS_BOLD_ITALIC)
  when :serif_bold, :bold_serif
    convert_text(str, SERIF_BOLD)
  when :small_caps, :small
    convert_text(str, SMALL_CAPS)
  when :circled
    convert_text(str, CIRCLED)
  when :circled_negative
    convert_text(str, CIRCLED_NEGATIVE)
  when :squared
    convert_text(str, SQUARED)
  when :squared_negative
    convert_text(str, SQUARED_NEGATIVE)
  when :double_struck
    convert_text(str, DOUBLE_STRUCK)
  when :inverted, :invert, :upside_down
    # This one reverses the return to make it really "backwards"
    convert_text(str, INVERTED).reverse
  when :reverse, :reversed, :backwards
    convert_text(str, REVERSED).reverse
  when :cyrillic, :russian
    convert_text(str, FAUX_CYRILLIC)
  else
    raise "Unknown style parameter given. Check SuperSub.styles to see a full list of valid text styles."
  end
end
convert_text(str, dictionary) click to toggle source
# File lib/supersub.rb, line 1499
def self.convert_text(str, dictionary)
  str.gsub(/[\w\W]/) { |character| dictionary[character] || character }
end
styles() click to toggle source
# File lib/supersub.rb, line 1507
def self.styles
  %i[superscript subscript script script_bold fullwidth monospace gothic gothic_bold sans sans_italic sans_bold sans_bold_italic serif_bold small_caps circled circled_negative squared squared_negative double_struck inverted reversed cyrillic]
end
test_string() click to toggle source
# File lib/supersub.rb, line 1503
def self.test_string
  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?!@#$%^&*()[]{}<>/\\\'"-_=+`~'
end