class FileInstaller
def initialize(file, target_dir)
@file = file
@target_dir = target_dir
end
def install
puts "Installing file #{@target_dir}/#{@file}"
# Code to install a file
end
def uninstall
puts "Uninstalling file #{@target_dir}/#{@file}"
# Code to UN-install a file
end
def backup
puts "Backing up file #{@target_dir}/#{@file}"
# Code to create a backup
end
end
|
|
- Class introduced by the class keyword
- Methods are defined by def
- initialize is like a constructor
- @file and @target_dir are instance variables. All instance variables begin with "@".
|