Skip to content
Snippets Groups Projects
Commit b3eff1c1 authored by pjs's avatar pjs
Browse files

lint-based cleanup

parent 502d7e09
No related branches found
No related tags found
No related merge requests found
require 'rubygems' require 'rubygems' if RUBY_VERSION =~ /^1\.8/
require 'skewheap' require 'skewheap'
# Including SimpleKit in your simulation model gives you methods +:run+, # Including SimpleKit in your simulation model gives you methods +:run+,
...@@ -12,19 +12,19 @@ module SimpleKit ...@@ -12,19 +12,19 @@ module SimpleKit
# Run your model by creating a new +EventScheduler+ and invoking its # Run your model by creating a new +EventScheduler+ and invoking its
# +run+ method. # +run+ method.
def run def run
@mySim = EventScheduler.new(self) @my_sim = EventScheduler.new(self)
@mySim.run @my_sim.run
end end
# If a method doesn't exist in the model class, try to delegate it. # If a method doesn't exist in the model class, try to delegate it.
def method_missing(name, *args) def method_missing(name, *args)
if DELEGATED_METHODS.include?(name) if DELEGATED_METHODS.include?(name)
@mySim.send(name, *args) @my_sim.send(name, *args)
else else
super super
end end
end end
# Class +EventScheduler+ provides the computation engine for a discrete # Class +EventScheduler+ provides the computation engine for a discrete
# event simulation model. It uses the +SkewHeap+ RubyGem as a priority # event simulation model. It uses the +SkewHeap+ RubyGem as a priority
# queue implementation for the pending events list. # queue implementation for the pending events list.
...@@ -51,7 +51,7 @@ module SimpleKit ...@@ -51,7 +51,7 @@ module SimpleKit
# - +args+ -> an optional list of arguments to pass to the event # - +args+ -> an optional list of arguments to pass to the event
# at invocation time. # at invocation time.
def schedule(event, delay, *args) def schedule(event, delay, *args)
raise "Model scheduled event with negative delay." if (delay < 0) fail 'Model scheduled event with negative delay.' if delay < 0
@event_list.push EventNotice.new(event, @model_time + delay, *args) @event_list.push EventNotice.new(event, @model_time + delay, *args)
end end
...@@ -64,7 +64,7 @@ module SimpleKit ...@@ -64,7 +64,7 @@ module SimpleKit
def run def run
@model_time = 0.0 @model_time = 0.0
@user_model.init @user_model.init
while (current_event = @event_list.pop) do while (current_event = @event_list.pop)
@model_time = current_event.time @model_time = current_event.time
@user_model.send(current_event.event, *current_event.args) @user_model.send(current_event.event, *current_event.args)
end end
...@@ -77,23 +77,23 @@ module SimpleKit ...@@ -77,23 +77,23 @@ module SimpleKit
end end
end end
private
# This is a private helper class for the EventScheduler class. # This is a private helper class for the EventScheduler class.
# Users should never try to access anything in this class directly. # Users should never try to access anything in this class directly.
private
class EventNotice class EventNotice
include Comparable include Comparable
attr_reader :event, :time, :args attr_reader :event, :time, :args
def initialize(event, time, *args) def initialize(event, time, *args)
@event = event @event = event
@time = time @time = time
@args = args @args = args
end end
def <=> (other) def <=>(other)
time <=> other.time time <=> other.time
end end
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment