Category:Ruby

  • Demonstrate six easily misunderstood features of ruby in real code

    Time:2019-11-22

    Introduction: suppose you are a C + + developer, you need to use ruby to quickly perform some prototyping. When you pick up a ruby reference book (such as pickaxe) or browse the ruby website, you will see some familiar constructs, such as class declaration, thread support and exception handling. Just when you think you […]

  • A tutorial of implementing a unit test framework in Ruby

    Time:2019-11-21

    I attended some workshops at the year Melbourne developers conference last year. These workshops are run by @ coreyhaines and @ rains, so TDD (Test Driven Development) is the main topic of discussion. Usually it’s not a problem, but it’s frustrating (considering this is the developer conference held in 2010). At that time, it wasn’t […]

  • A tutorial for creating a custom Ruby gem package

    Time:2019-11-20

    Write a simple example 1. Create the following folders Note: there must be a RB file with the same name as your gem in the Lib directory. Copy codeThe code is as follows:     $ cd hola      $ tree      .      ├── hola.gemspec      └── lib          └── hola.rb  2. Write code . […]

  • Socket programming tutorial in simple Ruby

    Time:2019-11-19

    Ruby provides two levels of network access services. At the bottom, you can access the operating system. It allows you to implement the basic socket support for connection oriented and Connectionless Protocols for clients and servers. Ruby supports network protocols of applications, such as FTP, HTTP, etc. Whether it’s high-level or low-level. Ruby provides some […]

  • A simple tutorial on working with XML and XSLT and XPath in Ruby

    Time:2019-11-18

    What is XML? XML refers to extensible markup language. Extensible markup language, a subset of standard general-purpose markup language, a markup language used to mark electronic documents to make them have structure. It can be used to tag data and define data types. It is a source language that allows users to define their own […]

  • A detailed tutorial on connecting databases in Ruby programs

    Time:2019-11-17

    This chapter will show you how to use ruby to access databases. The ruby DBI module provides a database independent interface for Ruby scripts similar to the Perl DBI module. DBI is database independent interface, which represents Ruby’s database independent interface. DBI provides an abstraction layer between Ruby code and the underlying database, allowing you […]

  • A basic course of object-oriented programming in Ruby

    Time:2019-11-16

    Ruby is a pure object-oriented language. Everything in ruby is in the form of objects. Every value in ruby is an object, even the most primitive things: strings, numbers, even true and false are objects. Class itself is an object, an instance of class. This chapter will show you all the main functions related to […]

  • A simple tutorial on writing a program to send mail in Ruby

    Time:2019-11-15

    SMTP (Simple Mail Transfer Protocol) is a simple mail transfer protocol. It is a set of rules used to transfer mail from the source address to the destination address. It controls the transfer mode of mail. Ruby provides net:: SMTP to send mail and two methods, new and start: The new method has two parameters: […]

  • A preliminary introduction to multithreading in Ruby Programming

    Time:2019-11-14

    Every program running on the system is a process. Each process contains one or more threads. Thread is a single sequential control process in a program. Running multiple threads simultaneously in a single program to complete different tasks is called multithreading. In ruby, we can use thread class to create multithreading. Ruby’s thread is a […]

  • A simple tutorial on using ruby to handle JSON

    Time:2019-11-13

    Environmental configuration Before using ruby to encode or decode JSON data, we need to install the ruby JSON module. You need to install Ruby gem before installing this module. We use Ruby gem to install JSON module However, if you are using the latest version of ruby, you may have installed gem. After parsing, we […]

  • Examples of five variables in Ruby

    Time:2019-11-12

    Ruby global variables Global variables start with $. The value of the uninitialized global variable is nil, which generates a warning when the – W option is used. Assigning a global variable changes the global state, so it is not recommended to use a global variable. The following example shows the use of global variables. […]

  • A tutorial on creating and using hashes in Ruby

    Time:2019-11-11

    Hash is a collection of key value pairs like “employee” = > salary. The hash index is completed by any key of any object type, not an integer index. Others are similar to arrays. The order in which hashes are traversed by keys or values seems arbitrary and is usually not in the insertion order. […]