Sha256: f20892a3ee1bcffa6189cdd84ba35f63c280f85aa6286c44d022babe7ef8badd

Contents?: true

Size: 900 Bytes

Versions: 2

Compression:

Stored size: 900 Bytes

Contents

module ConferenceTracker
  class Event
    NETWORKING = "Networking Event"

    class Constraint
      attr_reader :early_start

      def initialize(early_start)
        @early_start = Time.parse(early_start)
      end

      def valid?(time)
        time >= @early_start
      end
    end

    def self.lunch
      new("Lunch", "12PM")
    end

    def self.networking
      new("Networking Event", "4PM", Constraint.new("4PM"))
    end

    def initialize(name, start, constraint = nil)
      @name = name
      @start = ConferenceTracker.parse(start)
      @constraint = constraint
    end

    def to_s
      "#{early_start.strftime(FORMAT)} #{@name}"
    end

    def update(start)
      @start = ConferenceTracker.parse(start)
      self
    end

    private def early_start
      return @start if @constraint.nil? || @constraint.valid?(@start)
      @constraint.early_start
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
conference_tracker-1.1.1 lib/conference_tracker/event.rb
conference_tracker-1.1.0 lib/conference_tracker/event.rb