Sha256: e81ff622d1aed7a7c0e33f2d62a8a760b0e061935a1dde66ddafc2bbe0e200cd
Contents?: true
Size: 858 Bytes
Versions: 2
Compression:
Stored size: 858 Bytes
Contents
require "forwardable" module ConferenceTracker class Session extend Forwardable def self.morning new("9am", "12pm") end def self.afternoon new("1pm", "5pm") end def_delegators :@talks, :size, :empty? attr_reader :next_start def initialize(start, finish) @start = ConferenceTracker.parse(start) @finish = ConferenceTracker.parse(finish) @lapse = @finish - @start @talks = [] end def schedule @talks.map(&:to_s) end def add(talk) return if talk.scheduled? || overflow?(talk) @talks << talk.schedule(next_start) end def next_start @start + length end private def overflow?(talk) length + talk.to_i > @lapse end private def length @talks.reduce(0) { |length, talk| length += talk.to_i } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
conference_tracker-1.1.1 | lib/conference_tracker/session.rb |
conference_tracker-1.1.0 | lib/conference_tracker/session.rb |