Simplified Ruby is a minimal subset of the Ruby syntax that allows to take any problem description and turn it into idiomatic, easy to understand and boring Ruby code.
Ruby has a lot of features, quirks, and ways to solve the same problem. I believe that you can take 20% of its syntax and still be able to write code that does the job. This is especially true when you're using a framework (like Ruby on Rails) and a lot of technical problems are being handled for you.
Limiting yourself to Simplified Ruby shifts the focus from technical problems (exciting, but your company probably won't earn money for solving them) to business domain problems (here's your real leverage). You end up with code that is easy to read, easy to understand for your colleagues regardless of their seniority, and easy to delete.
This project can also be useful:
- when introducing people to programming
- to answer the question "how much Ruby syntax do I need to start writing Ruby on Rails applications?"
- during technical interviews for introductory Ruby positions
- for company career ladder to define "basic Ruby knowledge"
"adam"
:adam
56
3.4
nil
true
false"adam".upcase2 + 5.4
23 - 10
10 * 2
9 / 2
2 ** 3
8 % 3"this is #{4}."2 + 2 == 4
3 != 4"adam".length.zero? && 2 + 2 == 4
"adam".length.zero? || 2 + 2 == 4
!"adam".length.zero?if "adam".length.zero?
"awesome"
elsif 2 + 2 == 4
3
else
"something else"
end
"test" if 2 + 2 == 4[1, 2, 3]
{ "age" => 3 }{ age: 3 }name = "adam"age = 2 + 3
age = "five"def my_method(argument)
"I got #{argument}"
enddef my_method(argument)
return "a" if argument.zero?
"bbb"
enddef my_method(argument, name:, age: 18, city: nil)
end# this is how it works[1, 2].map do |element|
element * 2
endclass User
enduser = User.new("adam")class User
def name
"adam"
end
endclass User
def give_name(name)
@name = name
end
def name
@name
end
endclass User
def initialize(name)
@name = name
end
endclass User
def introduce
"I am #{age}"
end
private
def age
4
end
endclass User
def car
Car.new(self)
end
endclass User
def self.give_me_three
[User.new, User.new, User.new]
end
endclass User
CODE_LENGTH = 3
def code(name)
name.slice(0, CODE_LENGTH)
end
endclass User
def roles
[]
end
end
class Supervisor < User
def roles
["admin", "supervisor"]
end
endclass Supervisor < User
def code(name)
"#{super("ADMIN")} #{super}"
end
endclass Users
class Admin
end
end
Users::Admin.newclass User
attr_reader :name
attr_writer :ago
attr_accessor :city
endclass User
def give_name(name)
@name ||= name
end
endbegin
2 + 2
raise "error"
4 * 7
rescue => ex
"Aaaa #{ex}!!!"
end- Array#each
- Hash#each
- Enumerable#map
- Array#select
- Hash#select
- Enumerable#each_with_index
- Enumerable#inject
- Array#join
- Array#max
- Array#min
- Array#reverse
- Array#size
- Array#uniq
- Array#compact
- Array#include?
- Hash#fetch
- Hash#merge
- Hash#slice
- Enumerable#find
- Enumerable#group_by
- Emumerable#sort_by
- String#downcase
- String#upcase
- String#end_with?
- String#start_with?
- String#gsub
- String#include?
- String#length
- String#match?
- String#split