mirror of
https://github.com/clearlinux/dockerfiles.git
synced 2026-04-28 19:13:48 +00:00
29 lines
602 B
Ruby
29 lines
602 B
Ruby
class Computer
|
|
$manufacturer = "Apple Computer, Inc."
|
|
@@files = {hello: "Hello, world!"}
|
|
|
|
def initialize(username, password)
|
|
@username = username
|
|
@password = password
|
|
end
|
|
|
|
def current_user
|
|
@username
|
|
end
|
|
|
|
def self.display_files
|
|
@@files
|
|
end
|
|
end
|
|
|
|
# Make a new Computer instance:
|
|
hal = Computer.new("Dave", 12345)
|
|
|
|
puts "Current user: #{hal.current_user}"
|
|
# @username belongs to the hal instance.
|
|
|
|
puts "Manufacturer: #{$manufacturer}"
|
|
# $manufacturer is global! We can get it directly.
|
|
|
|
puts "Files: #{Computer.display_files}"
|
|
# @@files belongs to the Computer class. |