module Elixir::String

Public Instance Methods

at(string, index) click to toggle source
# File lib/elixir/string.rb, line 5
def at string, index
  string[index]
end
capitalize(string) click to toggle source
# File lib/elixir/string.rb, line 9
def capitalize string
  string.capitalize
end
chunk(string, trait) click to toggle source
# File lib/elixir/string.rb, line 13
def chunk string, trait
  # TODO
end
codepoints(string) click to toggle source
# File lib/elixir/string.rb, line 17
def codepoints string
  string.chars
end
contains?(string, contents) click to toggle source
# File lib/elixir/string.rb, line 21
def contains? string, contents
  warn '[deprecation] Calling String.contains?/2 with an empty string is deprecated and will fail in the future' if contents.empty?

  string.include? contents
end
downcase(string) click to toggle source
# File lib/elixir/string.rb, line 27
def downcase string
  string.downcase
end
duplicate(string, n) click to toggle source
# File lib/elixir/string.rb, line 31
def duplicate string, n
  string * n
end
ends_with?(string, *suffixes) click to toggle source
# File lib/elixir/string.rb, line 35
def ends_with? string, *suffixes
  warn '[deprecation] Calling String.ends_with?/2 with an empty string is deprecated and will fail in the future' if string.empty?

  string.end_with? *suffixes.flatten(1)
end
first(string) click to toggle source
# File lib/elixir/string.rb, line 41
def first string
  string[0]
end
graphemes(string) click to toggle source
# File lib/elixir/string.rb, line 45
def graphemes string
  string.chars
end
last(string) click to toggle source
# File lib/elixir/string.rb, line 49
def last string
  string[-1]
end
length(string) click to toggle source
# File lib/elixir/string.rb, line 53
def length string
  string.size
end
ljust(string, length, padding = ' ') click to toggle source
# File lib/elixir/string.rb, line 57
def ljust string, length, padding = ' '
  string.ljust length, padding
end
lstrip(string, char = :todo) click to toggle source
# File lib/elixir/string.rb, line 61
def lstrip string, char = :todo
  string.lstrip
end
match?(string, regex) click to toggle source
# File lib/elixir/string.rb, line 65
def match? string, regex
  # TODO
end
next_codepoint(string) click to toggle source
# File lib/elixir/string.rb, line 69
def next_codepoint string
  [string[0], string[1..-1]]
end
next_grapheme(string) click to toggle source
# File lib/elixir/string.rb, line 73
def next_grapheme string
  [string[0], string[1..-1]]
end
printable?(string) click to toggle source
# File lib/elixir/string.rb, line 77
def printable? string
  # TODO
end
replace(string, pattern, replacement, options = []) click to toggle source
# File lib/elixir/string.rb, line 81
def replace string, pattern, replacement, options = []
  # TODO
end
reverse(string) click to toggle source
# File lib/elixir/string.rb, line 85
def reverse string
  string.reverse
end
rjust(string, len, padding) click to toggle source
# File lib/elixir/string.rb, line 89
def rjust string, len, padding
  # TODO
end
rstrip(string, char = ' ') click to toggle source
# File lib/elixir/string.rb, line 93
def rstrip string, char = ' '
  # TODO
end
slice(string, range) click to toggle source
# File lib/elixir/string.rb, line 97
def slice string, range
  # TODO
end
split(string) click to toggle source
# File lib/elixir/string.rb, line 101
def split string
  string.split
end
split_at(string, offset) click to toggle source
# File lib/elixir/string.rb, line 105
def split_at string, offset
  # TODO
end
starts_with(string, prefix) click to toggle source
# File lib/elixir/string.rb, line 109
def starts_with string, prefix
  string.start_with? prefix
end
strip(string, char = nil) click to toggle source
# File lib/elixir/string.rb, line 113
def strip string, char = nil
  # TODO
end
to_atom(string) click to toggle source
# File lib/elixir/string.rb, line 117
def to_atom string
  string.to_sym
end
to_char_list(string) click to toggle source
# File lib/elixir/string.rb, line 121
def to_char_list string
  string.chars
end
to_existing_atom(string) click to toggle source
# File lib/elixir/string.rb, line 125
def to_existing_atom string
  # Nothing to see here... >.>
  if Symbol.all_symbols.map(&:to_s).include? string
    string.to_sym
  else
    raise ArgumentError
  end
end
to_float(string) click to toggle source
# File lib/elixir/string.rb, line 134
def to_float string
  Float(string)
end
to_integer(string, base = 10) click to toggle source
# File lib/elixir/string.rb, line 138
def to_integer string, base = 10
  Integer(string)
end
upcase(string) click to toggle source
# File lib/elixir/string.rb, line 142
def upcase string
  string.upcase
end
valid?(string) click to toggle source
# File lib/elixir/string.rb, line 146
def valid? string
  string.valid_encoding?
end
valid_character?(char) click to toggle source
# File lib/elixir/string.rb, line 150
def valid_character? char
  char.size == 1 && char.valid_encoding?
end