Sha256: e902aaa53b4f655337b3b433b432e5957ffd8ce445f0a5d71217bdf8f6560302

Contents?: true

Size: 651 Bytes

Versions: 3

Compression:

Stored size: 651 Bytes

Contents

module NetworkExecutive
  class LineupRange

    def initialize( start, stop, options = {} )
      @start, @stop, @options = start, stop, options

      @options[:interval] ||= 15
    end

    def each
      showtime = @start.dup

      while showtime < @stop
        yield showtime

        showtime += @options[:interval].minutes
      end
    end

    def each_with_object( obj )
      each do |showtime|
        yield showtime, obj
      end

      obj
    end

    # Divides a time span into segments specified by the 'interval' option
    def segments
      ( ( (@stop - @start) / 1.hour ) / @options[:interval] ).minutes.to_i
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
network_executive-0.0.4 app/models/network_executive/lineup_range.rb
network_executive-0.0.3 app/models/network_executive/lineup_range.rb
network_executive-0.0.2 app/models/network_executive/lineup_range.rb