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

  • Home
  • SEARCH
  • 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 6135073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:26:06+00:00 2026-05-23T17:26:06+00:00

class DobbsyKretts def initialize #Receive idea puts Enter an idea, a secret or anything

  • 0
class DobbsyKretts
  def initialize
    #Receive idea
    puts "Enter an idea, a secret or anything else you want to secretize; hit enter to stop typing and save the file"
    (@idea = gets).reverse.upcase
    #Filename and saving - to encrypt the file
    puts "Enter the file name you'd like to have this saved as; Type PLAN at the beginning for plans and REM for reminders"
    (@file_name = gets.chomp.upcase)
    File::open("DobbsyKrett-"+ @file_name + ".txt", "w") do |f|
      f << @idea
    end
  end

  def unzip
    puts "Do you want to withdraw PLAN or REM"
    response = gets.chomp.upcase!
    puts "Invalid" if !["PLAN","REM"].include?(response)
    file_contents = nil
    Dir['DobbsyKrett-'+response+"*.txt"].each do |file_nom|
      file_contents = File.read(file_nom)
    end
    puts file_contents
  end
end
somethingsomething1 = DobbsyKretts.new
somethingsomething1.unzip


  def unzip
    puts "Do you want to withdraw PLAN or REM"
    @response = gets.strip
    if @response.downcase != "plan" and @response.downcase != "rem"
      puts "Invalid" end
    Dir["DobbsyKrett-"+@response+".txt"].each do |file_nom|
      @value = file.read(file_nom)
    end
    puts @value
  end
end
  • 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-23T17:26:06+00:00Added an answer on May 23, 2026 at 5:26 pm

    The function gets will return a string with the line-ending character at the end which is not what you expected. To remove it, use the chomp function:

    @response = gets.chomp
    

    It is okay for a method (e.g. unzip) to create new instance variables (e.g. @valueholder). In general it’s always better for your variables to have the smallest possible scope, so unless you need to read valueholder later, you should just use a local variable (remove the @ from the name):

    Dir["DobbsyKrett-"+@response+".txt"].each do |file_nom|
      valueholder = File.read(file_nom)
    end
    puts valueholder
    

    Also, valueholder is a terrible name for a variable but if you made it a local variable that could be excused.

    Also, your block startings/endings are mismatched. Here’s a fixed version of your function that shouldn’t result in syntax errors:

    def unzip
      puts "Do you want to withdraw PLAN or REM"
      response = gets.chomp.downcase
      if !["plan","rem"].include? response
        puts "Invalid"
      else
        Dir["DobbsyKrett-#{response}.txt"].each do |file_nom|
          valueholder = file.read(file_nom)
        end
        puts valueholder
      end
    end
    

    Edit: You should capitalize File to correctly call File.read.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want this class to initialize to receive a message to be saved and
class A def set(v) @@v = v end def put puts @@v end end
class Ball: a = [] def __init__(self): pass def add(self,thing): self.a.append(thing) def size(self): print
class Article(models.Model): def user_may_see_full_version(self, user): # do something very sophisticated with the user return
class A: def x ( self ): print( self.__class__ ) class B ( A
class MainPage(webapp.RequestHandler): def get(self): user = users.get_current_user() tasks_query = Task.all() tasks = tasks_query.fetch(1000) if
class Foo(object): def __init__(self,x): self.x = x self.is_bar = False def __repr__(self): return str(self.x)
class CreateMatches < ActiveRecord::Migration def self.up create_table :matches do |t| t.integer :result_home t.integer :result_away
class X extends Map[String, String] { def x(): X = { X() } //
class Api::StoresController < ApplicationController respond_to :json def index @stores = Store.all(:include => :products) respond_with

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.