Skip to content

Instantly share code, notes, and snippets.

@oceansize
Created July 2, 2014 08:34
Show Gist options
  • Save oceansize/3a3df6832e07d92e8506 to your computer and use it in GitHub Desktop.
Save oceansize/3a3df6832e07d92e8506 to your computer and use it in GitHub Desktop.
def find_ascii_of(val)
@numero = [] # => []
val.each_byte do |x| # => "hello"
@numero << x # => [104], [104, 101], [104, 101, 108], [104, 101, 108, 108], [104, 101, 108, 108, 111]
end # => "hello"
return @numero # => [104, 101, 108, 108, 111]
end
def convert
@numero.map! do |x| # => [104, 101, 108, 108, 111]
x - 32 if (97..122).include? x # => 72, 69, 76, 76, 79
x.chr # => "h", "e", "l", "l", "o"
end # => ["h", "e", "l", "l", "o"]
@numero.join # => "hello"
end
def uppercasing(string)
find_ascii_of(string) # => [104, 101, 108, 108, 111]
convert # => "hello"
end
uppercasing('hello') # => "hello"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment