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'
# Including SimpleKit in your simulation model gives you methods +:run+,
......@@ -12,19 +12,19 @@ module SimpleKit
# Run your model by creating a new +EventScheduler+ and invoking its
# +run+ method.
def run
@mySim = EventScheduler.new(self)
@mySim.run
@my_sim = EventScheduler.new(self)
@my_sim.run
end
# If a method doesn't exist in the model class, try to delegate it.
def method_missing(name, *args)
if DELEGATED_METHODS.include?(name)
@mySim.send(name, *args)
@my_sim.send(name, *args)
else
super
end
end
# Class +EventScheduler+ provides the computation engine for a discrete
# event simulation model. It uses the +SkewHeap+ RubyGem as a priority
# queue implementation for the pending events list.
......@@ -51,7 +51,7 @@ module SimpleKit
# - +args+ -> an optional list of arguments to pass to the event
# at invocation time.
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)
end
......@@ -64,7 +64,7 @@ module SimpleKit
def run
@model_time = 0.0
@user_model.init
while (current_event = @event_list.pop) do
while (current_event = @event_list.pop)
@model_time = current_event.time
@user_model.send(current_event.event, *current_event.args)
end
......@@ -77,23 +77,23 @@ module SimpleKit
end
end
private
# This is a private helper class for the EventScheduler class.
# Users should never try to access anything in this class directly.
private
class EventNotice
include Comparable
attr_reader :event, :time, :args
def initialize(event, time, *args)
@event = event
@time = time
@args = args
end
def <=> (other)
def <=>(other)
time <=> other.time
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