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 7848443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:12:20+00:00 2026-06-02T18:12:20+00:00

In my lib folder I have billede.rb: class Billede require ‘RMagick’ #some code that

  • 0

In my lib folder I have billede.rb:

class Billede
  require 'RMagick'
  #some code that creates a watermark for a image
  image.write(out)
end

How do I call/activate the class? Is the only way to change it to a Rake task?

  • 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-06-02T18:12:23+00:00Added an answer on June 2, 2026 at 6:12 pm

    Code ‘inside a class’ is run just like any other code. If you have a Ruby file like this:

    puts "Hello from #{self}"
    class Foo
      puts "Hello from #{self}"
    end
    

    and you run the file (either via ruby foo.rb on the command line or require "./foo" or load "foo.rb" in a script) it then you will see the output:

    Hello from main
    Hello from Foo

    If you want to load a utility that ‘does something’ that you can then invoke from a REPL like IRB or the Rails console, then do this:

    module MyStuff
      def self.do_it
        # your code here
      end
    end
    

    You can require "./mystuff" to load the code, and when you’re ready to run it type MyStuff.do_it

    And, as you may guess, you can also create methods that accept arguments.

    If you want to define a file that can be included in others (with no immediate side effects) but which also “does its thing” whenever the file is run by itself, you can do this:

    module MyStuff
      def self.run!
        # Go
      end
    end
    
    MyStuff.run! if __FILE__==$0
    

    Now if you require or load this file the run! method won’t be invoked, but if you type ruby mystuff.rb from the command line it will.

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

Sidebar

Related Questions

So I have this code inside my lib/ folder: class GlobalConfig::SetHelper def self.yes_no_input(configuration) value
say I have jcifs-1.3.14.jar in my lib folder, and I have a class that
I was building my own class that resides in /lib folder and debugging with
I have written constant.rb in lib/ folder for my rails app.To use that in
I have a class sitting in /lib folder. It's in a file called mailing.rb
I'm using eclipse. In the WEB-INF/lib folder I have the following jars. jstl-api-1.2.jar jstl-impl-1.2.jar
I have a custom jar file in the tomcat lib/ folder. As per my
i have a jar file in my lib folder which is not in the
I have created a new library file sampler.rb inside the lib folder. Consider this
I have created one shell script in my lib folder. And i want to

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.