Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7431455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:17:56+00:00 2026-05-29T09:17:56+00:00

The other converts work, what do I need to do to get D) working

  • 0

The other converts work, what do I need to do to get D) working ok. Ultimately D) will be a cipher but I want to just get it working for each character for any function (downcase being an example) initially. The grouping into 5 character buckets is part of the cipher code I am developing.

def keystream_converter(message, conversion)
  case conversion.downcase
    when 'lower_case'
      message.upcase
    when 'upper_case'
      message.downcase
    when 'special'
      message.each_char { |ltr| ltr.downcase }
    else
      'invalid_conversion'
  end
end

initial_src =  "I see Ruby going 100 years!!"
test_string = (initial_src.delete('^a-zA-Z') +"X"*(initial_src.length % 5)).scan(/.{5}/).to_s.upcase
lower = keystream_converter(test_string, 'lower_case')
upper = keystream_converter(test_string, 'upper_case')
special = keystream_converter(test_string, 'special')
#
puts "A) - " + initial_src
puts "B) - " + upper
puts "C) - " + lower
puts "D) - " + special

Output:

A) - I see Ruby going 100 years!!
B) - ["iseer", "ubygo", "ingye", "arsxx"]
C) - ["ISEER", "UBYGO", "INGYE", "ARSXX"]
D) - ["ISEER", "UBYGO", "INGYE", "ARSXX"]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:17:57+00:00Added an answer on May 29, 2026 at 9:17 am

    String#each_char yields substrings of length 1 of the original string. If you change these substrings (even with downcase! and not a non-mutating downcase like in your case), original string will not be affected. If you want to use each_char with block, you can do something like this:

    message.each_char.map(&:downcase).join
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need converter to convert G729 or G711 files to wav,wma,mp3 or any other
i want to convert flv video(downloaded from you tube) to any other format, i
I read other threads like this but they didn't work for me. I got
At my work, we are on the 9/80 plan where we get every other
I need to convert strings in Python to other types such as unsigned and
I need to convert unicode strings in Python to other types such as unsigned
I have written some general functions to convert between decimal and any other base-n
I have a class that converts images and videos to other formats. A number
we are building a PHP script that we need at work to create reports
I am looking to use this plugin: http://keith-wood.name/countdown.html but I need to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.