万本电子书0元读

万本电子书0元读

顶部广告

The Ruby Workshop电子书

售       价:¥

2人正在读 | 0人评论 9.8

作       者:Akshat Paul

出  版  社:Packt Publishing

出版时间:2019-10-31

字       数:1407.6万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Cut through the noise and get real results with a step-by-step approach to learning Ruby programming. Key Features * Ideal for the Ruby beginner who is getting started with Ruby for the first time * A complete Ruby tutorial with exercises and activities that help build key skills * Structured to let you progress at your own pace, on your own terms * Use your physical copy to redeem free access to the online interactive edition Book Description You already know you want to learn Ruby, and the smarter way to learn Ruby 2.X is to learn by doing. The Ruby Workshop focuses on building up your practical skills so that you can kick-start your career as a developer and rapidly prototype applications. You'll learn from real examples that lead to real results. Throughout The Ruby Workshop, you'll take an engaging step-by-step approach to understanding the Ruby language. You won't have to sit through any unnecessary theory. If you're short on time you can jump into a single exercise each day or spend an entire weekend learning about metaprogramming. It's your choice. Learning on your terms, you'll build up and reinforce key skills in a way that feels rewarding. Every physical copy of The Ruby Workshop unlocks access to the interactive edition. With videos detailing all exercises and activities, you'll always have a guided solution. You can also benchmark yourself against assessments, track progress, and receive content updates. You'll even earn a secure credential that you can share and verify online upon completion. It's a premium learning experience that's included with your printed copy. To redeem, follow the instructions located at the start of your Ruby book. Fast-paced and direct, The Ruby Workshop is the ideal companion for Ruby beginners. You'll build and iterate on your Ruby code like a software developer, learning along the way. This process means that you'll find that your new skills stick, embedded as best practice. A solid foundation for the years ahead. What you will learn * Get to grips with the fundamentals of Ruby object-oriented programming * Understand common Ruby patterns to help minimize and easily maintain code * Explore ways to fetch, process, and output external data * Discover ways to work with public APIs and create reusable RubyGems * Keep your development process bug-free with various testing methods * Explore how to host applications on cloud application platforms like Heroku Who this book is for Our goal at Packt is to help you be successful, in whatever it is you choose to do. The Ruby Workshop is an ideal Ruby tutorial for the Ruby beginner who is just getting started. Pick up a Workshop today, and let Packt help you develop skills that stick with you for life.
目录展开

Preface

About the Book

About the Chapters

Conventions

Before You Begin

Installing Ruby 2.6

Installing the Code Bundle

1. Writing and Running Ruby Programs

Introduction

Key Features of Ruby

Object-Oriented

Interpreted Language

Duck Typing and Dynamic Typing

Multi-paradigm Language

Reflection

Metaprogramming

Interactive Ruby Shell (IRB)

Exercise 1.01: Creating and Assigning Variables

Exercise 1.02: Assigning a Variable of One Data Type to a Different Type

Exercise 1.03: Getting the Type of a Variable

Getting the Details of the Public Methods of an Object

Running Ruby Code from Ruby Files

Exercise 1.04: Getting User Input in a Ruby Program

Standard Data Types

Number

Exercise 1.05: Performing Common Integer Operations

Exercise 1.06: Using Common Integer Methods to Perform Complex Arithmetic

Floating-Point Numbers

Exercise 1.07: Performing Common Operations for Floating-Point Numbers

String

Exercise 1.08: Using Common String Methods

Exercise 1.09: Performing String Concatenation

Exercise 1.10: Performing String Interpolation

Exercise 1.11: Extracting and Searching a Substring from a String

Exercise 1.12: Replacing Part of a String with Another String

Exercise 1.13: Replacing All the Values inside a String Using gsub

Exercise 1.14: Splitting a String and Joining a String

Activity 1.01: Generating Email Addresses Using Ruby

Boolean

Activity 1.02: Calculating the Area and Perimeter of a Candy Manufacturing Plant

Summary

2. Ruby Data Types and Operations

Introduction

Arrays

Iterating Through an Array

Operations on Arrays

Merging Two Arrays

Removing Occurrences of Similar Elements from an Array

Inserting Elements into an Array at the End

Finding the Last Element of an Array without Modifying It

Finding the Last Element of an Array and Removing it

Exercise 2.01: Performing Simple Operations on Arrays

Creating an Array That Cannot Be Modified

Finding All the Unique Elements in an Array

Sorting the Elements of an Array

Finding the Number of Elements in an Array

Establishing Whether an Element Exists in an Array (Case-Sensitive)

Converting Elements of an Array into a String

Exercise 2.02: Performing Complex Operations on Arrays

Hashes

Operations on Hashes

Getting Values from the Hash

Sorting a Hash

Merging Hashes

Retrieving Keys or Values from a Hash

Deleting a Value from a Hash by Key

Removing or Rejecting Elements from a Hash

Establishing whether a Hash Contains a Particular Value

Exercise 2.03: Converting a Time String to a Hash

Ruby Methods

Passing Arguments to a Method

Ruby Methods with Default Values

Return Value(s) from Methods

Naming Conventions for Methods

Activity 2.01: Dice Roller Program

Summary

3. Program Flow

Introduction

Boolean Operators

The AND Operator

The OR Operator

The NOT Operator

Truth Tables

Truthiness

Precedence

Exercise 3.01: Implementing Boolean Operators

Conditional Expressions

The if Statement

The else Statement

The elsif Statement

The unless Statement

Comparison

Comparison Operators

Comparing Strings

Exercise 3.02: Creating a Method to Check Your Balance

The case/when Statement

The === Operator

The Ternary Operator

Exercise 3.03: Speed Determiner

Loops

The while/do Loop

Exercise 3.04: Developing a Mind Reader

The until/do Loop

The do/while Loop

Iterators and Enumerators

The each Method

The each_with_index Method

The map/collect Loop

Exercise 3.05: Developing an Arbitrary Math Method

Activity 3.01: Number-Guessing Game

Summary

4. Ruby Methods

Introduction

The Basic Structure of the Ruby Method

Method Components: Signature and Implementation

The Method Signature

Method Arguments

Positional Arguments

Variable Scope

Optional Parentheses and Code Style

Mandatory and Optional Arguments

Keyword Arguments

Return Values

Multiple Return Values

Exercise 4.01: Performing Operations on an Array

The Splat Operator

The Single Splat (*) Operator

The Double Splat (**) Operator

Exercise 4.02: Creating a Method to Take Any Number of Parameters

Duck Typing

Sending a Message

Using Built-In Modules: Time and Math

Math

Exercise 4.03: Using the Math Library to Perform Mathematical Operations

Time

Exercise 4.04: Performing Method Operations with the Time Module

Activity 4.01: Blackjack Card Game

Summary

5. Object-Oriented programming with Ruby

Introduction

Classes and Objects

Instance Methods

Getters and Setters

Exercise 5.01: Modeling a Company's Organizational Chart Using Classes

Class Methods

Method 1: Calling a Method Directly on the Class

Method 2: Using the self Keyword

Class Variables

Exercise 5.02: Generating URLs for Sharing Content on Social Platforms

Inheritance

The Inheritance of Methods

The Inheritance of Variables

Calling super

The Different Ways to Call super

Calling super without Arguments

Calling super with Arguments

Calling super with the Naked Splat Operator

Exercise 5.03: Modelling a Class for Location Addresses

Encapsulation

Public Methods

Private Methods

Protected Methods

Exercise 5.04: Demonstrate the Visibility Rules of Ruby Methods

Bypassing Visibility

A Quick Note about File Organization

Activity 5.01: Voting Application for Employee of the Month

Summary

6. Modules and Mixins

Introduction

Including Modules

Exercise 6.01: Controlling the Operations of Services in an Application

Inheritance with Module Methods

Inclusion Ordering

extend

Exercise 6.02: Extending Your Modules with Class and Instance Methods

Module Callbacks

Exercise 6.03: Using Module Functions to Extend Classes

Importing Modules as Class Methods using Extended

Combining include and extend

Enumerated Types

Exercise 6.04: Writing a Module to Define Payment Methods for a Product Application

Module Methods

Namespaces

Exercise 6.05: How to Reuse Constants with a Namespace

prepend

prepend with Subclasses

Exercise 6.06: Prepending Modules to Classes

Activity 6.01: Implementing Categories on the Voting Application Program

Summary

7. Introduction to Ruby Gems

Introduction

RubyGems and the require Method

gem search

gem install

gem dependency

gem Versioning

gem list

Using Gems in Your Code

Exercise 7.01: Installing and Using a Ruby Gem

File I/O

Creating Files

Reading Files

Using the File.read Method

Using the File.open Method

Using the File.foreach Method

read versus open versus foreach

Writing to Files

Using the File.new Method (Initializer)

Using the File.open Method with a Block Method

Using the File.write Method

File.open versus File.new

File Modes

File Helpers

Handling CSV Data

Reading Data from a CSV File Using CSV.read

Using Column Headers as Field Names

Exercise 7.02: Reading Data from a .csv File and Printing a Few Columns

Reading Data from a .csv File Using CSV.foreach

Response Type Variations

Writing Data

Writing CSV Data from an Enumerable

Exercise 7.03: Writing an Array of Users to a CSV File

Service Objects

The Single Responsibility Principle

Service Objects versus Modules

Class Method Execution

Exercise 7.04: Building a Service Object

Activity 7.01: Presenting Voting Data in CSV Format Using Ruby Gems

Summary

8. Debugging with Ruby

Introduction

Logging and Debugging

Logging with the logger Class

Basic Logging

Log Levels

Exercise 8.01: Logging User Information

Exercise 8.02: Creating a Basic Exception Logger

Setting Log Levels by String

Log Output

STDOUT

STDERR

File

Log Formatting

Custom Date Formats

Custom String Formats

Time Zones and UTC

Log File Management

Size-Based Retention

Time-Based Retention

Exercise 8.03: Creating a Rolling Log File

Debugging

Debugging Concepts

Breakpoints

Stack Trace/Call Stack/Back Trace

Viewing the Stack Trace

StepOver, StepInto, and StepOut

Debugging via the CLI with byebug

Conditional Debugging

Navigating with byebug

Exercise 8.04: Debugging with byebug

Debugging with Visual Studio Code

Setting Breakpoints

Logpoints

The Debug Console

Exercise 8.05: Debugging with Visual Studio Code

Activity 8.01: Perform Debugging on a Voting Application

Summary

9. Ruby Beyond the Basics l

Introduction

Metaprogramming

Blocks

Syntax for Blocks

With do/end

With curly brackets ({})

yield with Blocks

Exercise 9.01: Building a Simple Calculator

block_given? with Blocks

Exercise 9.02: Building a Flight Status Display System

The proc Object

Exercise 9.03: Performing the sum Function on a Range of Numbers

Exercise 9.04: Calculating Profit Using proc on an Input Price List

Lambdas

Exercise 9.05: Creating a Program to Sum a Range of Numbers Using Lambdas

proc versus lambda

The Story of the Chef and the Restaurant

Activity 9.01: Invoice Generator

Summary

10. Ruby Beyond the Basics ll

Introduction

Metaprogramming – A Deep Dive

Opening Classes

Exercise 10.01: Opening the Ruby String Class to Add a New Method to it

Monkey Patching

Exercise 10.02: Using Monkey Patching to Add/Subtract Values

method_missing

Exercise 10.03: Managing Ghost Methods for the Company Class

The Define Method

Exercise 10.04: Creating a Welcome Message Program Using define_method

HTTP Requests

HTTP Requests with Ruby

Exercise 10.05: Creating a Ruby Program to Make a Successful GET Request

Status Codes

Exercise 10.06: Creating a POST Request Using Ruby

Creating a Ruby Gem

Exercise 10.07: Creating Your Own Ruby Gem

Activity 10.01: Implementing GET and POST Data to an External Server

Summary

11. Introduction to Ruby on Rails l

Introduction

MVC

Model

View

Controller

Generating Our First Rails App

Exercise 11.01: Generating a Simple Rails Application

Anatomy of a Rails application

Exercise 11.02: Replacing the Default Page

Exercise 11.03: Displaying a Page Heading from the Value Served from Its Action

Extending Our View and Controller

Exercise 11.04: Adding a Resource to the Rails Application

Models, Migrations, and Databases

Exercise 11.05: Creating a Review Model for citireview

The Rails Console

Exercise 11.06: Completing the Reviews Web Application

The devise Ruby Gem

Activity 11.01: Adding Authentication for the Review Application

Summary

12. Introduction to Ruby on Rails ll

Introduction

Associations

belongs_to

has_one

has_many

has_many :through

has_one :through

has_and_belongs_to_many

Exercise 12.01: Creating a Model to Enable Users to Comment on Reviews on the CitiReview Application

Validations

Database Validations

Controller-Level Validations

Client-Side Validations

Model-Level Validations

Methods that Trigger Validations

Methods that Skip Validations

Checking Validations

Exercise 12.02: Adding Validation for the Citireview Application

Scaffolding

Exercise 12.03: Using Rails Scaffolding to Create a Rails Application for a Store with a List of Products

Activity 12.01: Create a Blog Application and Host It Live on a Cloud Platform

Summary

Appendix

1. Writing and Running Ruby Programs

Activity 1.01: Generating Email Addresses Using Ruby

Activity 1.02: Calculating the Area and Perimeter for a Candy Manufacturing Plant

2. Ruby Data Types and Operations

Activity 2.01: Dice Roller Program

3. Program Flow

Activity 3.01: Number-Guessing Game

4. Ruby Methods

Activity 4.01: Blackjack Card Game

5. Object-Oriented Programming with Ruby

Activity 5.01: Voting Application for Employee of the Month

6. Modules and Mixins

Activity 6.01: Implementing Categories on the Voting Application Program

7. Introduction to Ruby Gems

Activity 7.01: Presenting Voting Data in CSV Format Using Ruby Gems

8. Debugging with Ruby

Activity 8.01: Perform Debugging on a Voting Application

9. Ruby Beyond the Basics I

Activity 9.01: Invoice Generator

10. Ruby Beyond the Basics II

Activity 10.01: Implementing GET and POST Data to an External Server

11. Introduction to Ruby on Rails I

Activity 11.01: Adding Authentication for the Review Application

12. Introduction to Ruby on Rails II

Activity 12.01: Create a Blog Application and Host It Live on a Cloud Platform

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部