Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_figlet/parser.rb,
lib/ruby_figlet/interface.rb

Instance Method Summary collapse

Instance Method Details

#delete_at(n) ⇒ Object



13
14
15
# File 'lib/ruby_figlet/parser.rb', line 13

def delete_at n
  dup.delete_at! n
end

#delete_at!(n) ⇒ Object



9
10
11
12
# File 'lib/ruby_figlet/parser.rb', line 9

def delete_at! n
  slice! n
  self
end

#eachObject



2
3
4
5
6
7
8
# File 'lib/ruby_figlet/interface.rb', line 2

def each
  i = 0
  while i < self.length
    yield self[i]
    i += 1
  end
end

#to_utf8Object



2
3
4
5
6
7
# File 'lib/ruby_figlet/parser.rb', line 2

def to_utf8
  str = self.force_encoding("UTF-8")
  return str if str.valid_encoding?
  str = str.force_encoding("BINARY")
  str.encode("UTF-8", invalid: :replace, undef: :replace)
end