Computer Science

Ruby programming language

Ruby is a high-level, interpreted programming language that is known for its simplicity and productivity. It is object-oriented and dynamically typed, making it easy to write and read code. Ruby is commonly used for web development, scripting, and automation.

Written by Perlego with AI-assistance

2 Key excerpts on "Ruby programming language"

  • Programming Language Explorations
    • Ray Toal, Rachel Rivera, Alexander Schneider, Eileen Choe(Authors)
    • 2016(Publication Date)
    But Ruby does have many, many fans, who find the language beautiful, powerful, and expressive. Of the many languages that influenced Ruby, two stand out. It’s a scripting language like Perl, with operating system interfaces, string processing, regular expressions, and various syntactic niceties like flexible quoting syntaxes. Ruby’s other major influence is Smalltalk. Ruby is object-oriented in the way Smalltalk is object-oriented, expressing nearly all computation with message passing. Ruby’s blocks come from Smalltalk, too. And the metaprogramming facilities of Ruby are, as in Smalltalk, an area in which the language really shines.
    Many programmers today know Ruby from the web frameworks built upon it, most notably Rails, but also Sinatra, Camping, Rack, Padrino, Pancake, Monk, and others. But Ruby is truly a general-purpose language, and you’ll see it used in many popular applications. Its lineage as a scripting language makes it popular among operations teams; in fact, popular automation and testing tools like Puppet, Chef, and Vagrant are written in Ruby. Ruby’s uncanny ability to implement domain-specific languages (DSLs) also fuels its popularity across domains.
    Our Ruby tour will begin with our standard three example programs and a brief overview of the language. We will then introduce the object-oriented paradigm and show how Ruby makes object-oriented programming not only possible but natural. Ruby is the first, and only, language in this text that we will bother to label object-oriented, and we’ll explain why. We’ll then proceed to two important features of Ruby: blocks and mixins. These features will be followed by a section on access control, a feature Ruby makes relatively easy compared to the four languages we have seen up until now. We round out our coverage with Ruby’s metaprogramming facilities.
    5.1  HELLO RUBY We begin with our familiar script to list small right triangle measurements:
    Ruby sports a couple features we first saw in CoffeeScript—string interpolation with #{} and a trailing if -clause—but this little script is definitely not using a traditional for -statement. Instead, we start the script by sending the message upto to the object 1 . The message is sent with with argument 40 and a block (here delimited with do and end). The upto
  • The Ruby Workshop
    eBook - ePub

    The Ruby Workshop

    A New, Interactive Approach to Learning Ruby

    • Akshat Paul, Peter Philips, Dániel Szabó, Cheyne Wallace(Authors)
    • 2019(Publication Date)
    • Packt Publishing
      (Publisher)

    5. Object-Oriented programming with Ruby

    Overview
    By the end of this chapter you will be able to describe the basics of object-oriented programming using Ruby; model data with classes; implement instance and class variables in Ruby programs; write instance and class methods in application programs; and evaluate getters and setters in Ruby.

    Introduction

    In the previous chapter, we studied different methods and parameters of Ruby. We also learned about the built-in libraries of Math and Time in Ruby. It was here that we began to introduce the concepts of classes and modules. In this chapter, we will dive deeper into Ruby classes using object-oriented programming (OOP) concepts as our guide.
    OOP is where the rubber meets the road in programming. In other words, this is where the action happens. If you want to write a quick script or a full-fledged application, the chances are you will use OOP. OOP has the following benefits:
    • It is easy to design programs, as OOP concepts help greatly in the organization of concepts in everyday life.
    • It breaks hard problems down into manageable pieces for coding.
    • It is easy to test.
    • It is easy for others to read and learn how the program works.
    • It provides foundational units that can be easily extended or built upon, so as to construct robust applications.
    OOP facilitates writing code in a way that allows you to think about, and model, the concepts that you are working with in your program. For instance, imagine that you are tasked to write an application that allows all your coworkers to vote on who they think should be the employee of the month. You are most likely going to need code that deals with the abstract concepts in a voting system such as a user, a vote, and some code for grouping votes in a certain time period.
    This kind of thinking and modeling is also known as domain modeling. The problem domain is everything involved in trying to solve the problem. In the preceding case, the problem domain is an employee-of-the-month voting system. OOP is the tactical way of solving that problem by splitting our problem domain specifically into domain models using objects and classes.
Index pages curate the most relevant extracts from our library of academic textbooks. They’ve been created using an in-house natural language model (NLM), each adding context and meaning to key research topics.