class OperatingSystem
Attributes
name[RW]
shortcut[RW]
Public Class Methods
all()
click to toggle source
# File lib/operating_system.rb, line 48 def self.all @@all end
create_operating_system(name)
click to toggle source
# File lib/operating_system.rb, line 42 def self.create_operating_system(name) os = OperatingSystem.new(name) os.save os end
find_by_name(name)
click to toggle source
# File lib/operating_system.rb, line 29 def self.find_by_name(name) @@all.detect {|os| os.name == name} end
find_or_create_operating_system(name)
click to toggle source
# File lib/operating_system.rb, line 33 def self.find_or_create_operating_system(name) os = OperatingSystem.all.detect {|os_object| name == os_object.name} if os.nil? create_operating_system(name) else os end end
new(name= nil)
click to toggle source
# File lib/operating_system.rb, line 7 def initialize(name= nil) @name = name @shortcuts = [] end
Public Instance Methods
add_shortcut(shortcut)
click to toggle source
# File lib/operating_system.rb, line 20 def add_shortcut(shortcut) @shortcuts << shortcut shortcut.operating_system = self end
save()
click to toggle source
# File lib/operating_system.rb, line 12 def save @@all << self end
shortcuts()
click to toggle source
# File lib/operating_system.rb, line 16 def shortcuts @shortcuts end
sort_alphabetically()
click to toggle source
# File lib/operating_system.rb, line 25 def sort_alphabetically @shortcuts = shortcuts.collect.sort_by {|obj| obj.name} end