售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Title Page
Copyright
Comprehensive Ruby Programming
Credits
About the Author
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Introduction to the Ruby Programming Language
What is Ruby?
Popular sites that use Ruby
Installing Ruby on a computer
Ruby language dashboard
Installing different Ruby versions with RVM
Summary
Ruby Variables
Using variables in Ruby
Variable code implementation
Printing to the Ruby console
Using puts
Using p
Getting input from the Ruby console using gets and chomp
Code implementation
Variable scope and variable types
Local variables
Global variables
Instance variables
Constants
Class variables
Summary
Ruby Strings
Using strings in Ruby
Missing quotation marks
Printing strings
Storing strings in variables
String interpolation guide for Ruby
What is string interpolation?
String manipulation guide
What is string manipulation?
String manipulation code examples
Method chaining
A practical implementation
Give it a bang!
String substitution guide
Adding a bang
Becoming a block head
Split, strip, and join guides for strings
Using the strip method
Using the split method
Using the join method
Summary
Working with Numbers in Ruby
Integer arithmetic guide
Arithmetic order of operations
Difference between integers and floats
Summary
Ruby Methods
Creating methods in Ruby
What does a Ruby method return?
What are the differences between class and instance methods in Ruby?
Ruby proc tutorial
Proc code example
What is a block?
The Ruby lambda tutorial
Stabby lambdas
What is the difference between procs and lambdas in Ruby?
Argument count
Return behavior
Guide to method arguments in Ruby
What are method arguments?
Method argument syntax
Method argument code examples
Named arguments
Default argument values
Using splat and optional arguments in Ruby methods
Traditional splat arguments
Keyword-based splat arguments
Optional arguments
Summary
Ruby Iterators and Loops
The while loop guide
The while loop code example
The each iterator method tutorial
The each loop code example
The for...in loops tutorial
Looping over a hash
Nested iterator code example
Using the select method
Using the map method – part 1
The map method code example
Using the map method – part 2
Summing values in an array using the inject method
Summary
Ruby Collections
Using arrays
Deleting items from arrays
Using push and pop for arrays
The Ruby hash tutorial
The hash code example
Deleting elements from a hash
Iterating over a hash for a key or value
Top hash methods in Ruby
Adding elements to a hash
Swapping keys and values
Merging hashes
Converting a hash into an array
Listing all keys
Listing all values
Summary
Ruby Conditionals
The conditionals guide
Real-world use of conditionals
Code example of conditionals
Syntax for the unless conditional
Running Ruby files
The unless conditional code example
Nested if...else conditionals
The if...elsif conditional code example
The conditional workflow
Guide to compound conditionals
Compound conditionals code example
Compounded compound conditionals
Additional conditional operators
Summary
Object-Oriented Programming in Ruby
Introduction to how OOP works
A real-world OOP example
Ruby OOP development – setters, getters, and methods
Working with instantiation in Ruby
What does instantiation mean? – A real-world example
Connecting the dots
Instantiation code example
Implementing instantiation
Creating an initializer method in a Ruby class
Adding an initializer to a Ruby class
Working with optional values
Using named arguments
Overriding default values
The working of OOP inheritance
Overview of private versus public methods
Private versus public methods
Private method code example
The working of polymorphism and usage of super
So how does polymorphism fit in?
Dead simple OOP
My history with OOP
How does OOP work?
SOLID OOP development – the simple responsibility principle
The single responsibility principle
The SRP in the real world
An SRP example
The class that knew too much
Rule of thumb – no ands allowed
A mailer class
The sales tax class
Why the SRP is important
SOLID OOP development – the open/closed principle guide and example
The open/closed principle definition
A surprisingly challenging task
The open/closed principle example
The naive approach
I don't like change!
A better way
SOLID OOP development – the Liskov substitution principle
The LSP definition
Breaking down the LSP
The LSP example
The problem
The LSP violation
The fix
SOLID OOP development – the interface segregation principle
The ISP definition
The ISP code example
Introducing the moderator
A better way
The result
A caveat
SOLID OOP development – the dependency inversion principle
The DIP in the real world
The DIP definition
The DIP code example
Recap
Summary
Working with the Filesystem in Ruby
Creating a file
Ruby File class
Other options you can pass as the second option
Reading files into a program using the File class
Deleting a file
Appending a file
Building a log file
Summary
Error Handling in Ruby
Error handling tutorial
Error handling – the best practices
Developing a custom error logger in Ruby
Summary
Regular Expressions in Ruby
Regular expression code example
Regex code example
How to validate an IP address using regular expressions
How to develop a wheel of fortune game
Summary
Searching with grep in Ruby
How to use grep in Ruby
How to use grep instead of the select and map methods
Summary
Ruby Gems
Introduction to Ruby gems
How to research Ruby gems
How to research gems
Summary
Ruby Metaprogramming
Metaprogramming introduction
How to integrate metaprogramming techniques into a custom class
How to use metaprogramming for opening and customizing the String class
How Rails use metaprogramming for the find_by method
Utilizing metaprogramming with method_missing to create methods on the fly
Why do we need to call super?
Resources
Incorporating respond_to_missing to conform to metaprogramming best practices
Resources
Implementing metaprogramming with define_method
Resources
Summary
Ruby Web Frameworks
Sinatra web framework development
Introduction to the Ruby on Rails framework
Summary
Working with APIs in Ruby
How to work with APIs in Ruby
How to use the httparty Ruby gem
How to create a custom API connector in Ruby
How to parse an API in Ruby
Summary
Ruby Algorithms
Introduction to sorting algorithms
Bubble sort
Quick sort
Merge sort
Implementing the bubble sort algorithm
Bubble sort code example
Implementing the quick sort algorithm
Explanation of quick sort
Quick sort code example
Implementing the merge sort algorithm
Implementing a prime number counting algorithm
How to code the power digit sum algorithm
Implementing a humanize counting algorithm
Implementing a date algorithm
How to code a Fibonacci digit counter
Implementing a permutation algorithm
Implementing an amicable number algorithm
Implementing a factorial algorithm
Implementing an even Fibonacci number algorithm
Implementing the least common multiple
Summary
Machine Learning
Big data analysis
Basic decision tree implementation
Addition of attributes
Addition of training data and its values
Calling the ID3 method
Function of the train method
Addition of the test method
Setting up decision variables
Print the results out
Testing the program
Advantage of decision trees over if...else statements
How to develop a big data analysis application in Ruby
Summary
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜