Ruby Class Example
Object-oriented programming with Ruby:
# Simple class
class Greeter
def initialize(name)
@name = name
end
def greet
puts "Hello, #{@name}!"
end
end
# Usage
user = Greeter.new('World')
user.greet
# Symbols and regex
status = :ok
pattern = /foo.+bar/i
# Percent literals
words = %w{alpha beta gamma}
# Command
output = `uname -a`