Sha256: ebafd7447a19136faced1d7ab3751eb2099bc1c1ec639775c89b5895c9938003
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module SportsManager # NOTE: maybe change the name since we are not creating a Timeslot object here # Public: Builds the possible timeslots as Time objects class TimeslotBuilder require 'time' require 'forwardable' extend Forwardable attr_reader :tournament_day def_delegators :tournament_day, :start_hour, :end_hour, :date def self.build(tournament_day:, interval:) new(tournament_day: tournament_day, interval: interval).build end def initialize(tournament_day:, interval:) @tournament_day = tournament_day @interval = interval end def build time_range.step(interval).map(&Time.method(:at)) end private def time_range (start_time.to_i..end_time.to_i) end def interval @interval * 60 end def start_time parse_time(start_hour) end def end_time parse_time(end_hour) end def parse_time(time) Time.parse("#{date}T#{time}:00:00") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sports-manager-0.0.3 | lib/sports_manager/timeslot_builder.rb |
sports-manager-0.0.2 | lib/sports_manager/timeslot_builder.rb |
sports-manager-0.0.1 | lib/sports_manager/timeslot_builder.rb |