### Home Classes Methods

### In Files

- lib/taskjuggler/Scoreboard.rb

### Parent

Object

### Methods

- ::new
- #[]
- #[]=
- #clear
- #collect!
- #collectIntervals
- #dateToIdx
- #each
- #each_index
- #get
- #idxToDate
- #inspect
- #set

### Files

- CHANGELOG
- COPYING
- README.rdoc

### Class/Module Index

Quicksearch

- TaskJuggler
- TaskJuggler::Account
- TaskJuggler::AccountAttribute
- TaskJuggler::AccountCredit
- TaskJuggler::AccountCreditListAttribute
- TaskJuggler::AccountListRE
- TaskJuggler::AccountScenario
- TaskJuggler::AlertLevelDefinition
- TaskJuggler::AlertLevelDefinitions
- TaskJuggler::Allocation
- TaskJuggler::AllocationAttribute
- TaskJuggler::AttributeBase
- TaskJuggler::AttributeDefinition
- TaskJuggler::AttributeOverwrite
- TaskJuggler::BatchProcessor
- TaskJuggler::Booking
- TaskJuggler::BookingListAttribute
- TaskJuggler::BooleanAttribute
- TaskJuggler::CSVFile
- TaskJuggler::CellSettingPattern
- TaskJuggler::CellSettingPatternList
- TaskJuggler::Charge
- TaskJuggler::ChargeListAttribute
- TaskJuggler::ChargeSet
- TaskJuggler::ChargeSetListAttribute
- TaskJuggler::ChartPlotter
- TaskJuggler::ChartPlotterError
- TaskJuggler::CollisionDetector
- TaskJuggler::ColumnListAttribute
- TaskJuggler::ColumnTable
- TaskJuggler::Daemon
- TaskJuggler::DaemonConnector
- TaskJuggler::DaemonConnectorMixin
- TaskJuggler::DataCache
- TaskJuggler::DataCacheEntry
- TaskJuggler::DateAttribute
- TaskJuggler::DefinitionListAttribute
- TaskJuggler::DependencyListAttribute
- TaskJuggler::DurationAttribute
- TaskJuggler::ExportRE
- TaskJuggler::FileList
- TaskJuggler::FileRecord
- TaskJuggler::FixnumAttribute
- TaskJuggler::FlagListAttribute
- TaskJuggler::FloatAttribute
- TaskJuggler::FormatListAttribute
- TaskJuggler::GanttChart
- TaskJuggler::GanttContainer
- TaskJuggler::GanttHeader
- TaskJuggler::GanttHeaderScaleItem
- TaskJuggler::GanttLine
- TaskJuggler::GanttLoadStack
- TaskJuggler::GanttMilestone
- TaskJuggler::GanttRouter
- TaskJuggler::GanttTaskBar
- TaskJuggler::HTMLDocument
- TaskJuggler::HTMLElements
- TaskJuggler::HTMLGraphics
- TaskJuggler::ICalReport
- TaskJuggler::ICalendar
- TaskJuggler::ICalendar::Component
- TaskJuggler::ICalendar::Event
- TaskJuggler::ICalendar::Journal
- TaskJuggler::ICalendar::Person
- TaskJuggler::ICalendar::Todo
- TaskJuggler::Interval
- TaskJuggler::IntervalList
- TaskJuggler::JobInfo
- TaskJuggler::Journal
- TaskJuggler::JournalEntry
- TaskJuggler::JournalEntryList
- TaskJuggler::JournalSortListAttribute
- TaskJuggler::KateSyntax
- TaskJuggler::KeywordArray
- TaskJuggler::KeywordDocumentation
- TaskJuggler::Leave
- TaskJuggler::LeaveAllowance
- TaskJuggler::LeaveAllowanceList
- TaskJuggler::LeaveAllowanceListAttribute
- TaskJuggler::LeaveList
- TaskJuggler::LeaveListAttribute
- TaskJuggler::Limits
- TaskJuggler::Limits::Limit
- TaskJuggler::LimitsAttribute
- TaskJuggler::ListAttributeBase
- TaskJuggler::Log
- TaskJuggler::LogicalAttribute
- TaskJuggler::LogicalExpression
- TaskJuggler::LogicalExpressionAttribute
- TaskJuggler::LogicalExpressionListAttribute
- TaskJuggler::LogicalFlag
- TaskJuggler::LogicalFunction
- TaskJuggler::LogicalOperation
- TaskJuggler::ManagerResponsibilities
- TaskJuggler::ManagerStatusRecord
- TaskJuggler::Message
- TaskJuggler::MessageHandler
- TaskJuggler::MessageHandlerInstance
- TaskJuggler::MspXmlRE
- TaskJuggler::Navigator
- TaskJuggler::NavigatorElement
- TaskJuggler::NikuProject
- TaskJuggler::NikuReport
- TaskJuggler::NikuResource
- TaskJuggler::NodeListAttribute
- TaskJuggler::PTNProxy
- TaskJuggler::Painter
- TaskJuggler::Painter::Circle
- TaskJuggler::Painter::Color
- TaskJuggler::Painter::Element
- TaskJuggler::Painter::Ellipse
- TaskJuggler::Painter::FontMetrics
- TaskJuggler::Painter::FontMetricsData
- TaskJuggler::Painter::Group
- TaskJuggler::Painter::Line
- TaskJuggler::Painter::Points
- TaskJuggler::Painter::PolyLine
- TaskJuggler::Painter::Primitives
- TaskJuggler::Painter::Rect
- TaskJuggler::Painter::SVGSupport
- TaskJuggler::Painter::Text
- TaskJuggler::PlaceHolderCell
- TaskJuggler::ProcessIntercom
- TaskJuggler::ProcessIntercomIface
- TaskJuggler::Project
- TaskJuggler::ProjectBroker
- TaskJuggler::ProjectBrokerIface
- TaskJuggler::ProjectFileParser
- TaskJuggler::ProjectFileScanner
- TaskJuggler::ProjectRecord
- TaskJuggler::ProjectServer
- TaskJuggler::ProjectServerIface
- TaskJuggler::PropertyAttribute
- TaskJuggler::PropertyList
- TaskJuggler::PropertySet
- TaskJuggler::PropertyTreeNode
- TaskJuggler::Query
- TaskJuggler::RTFHandlers
- TaskJuggler::RTFNavigator
- TaskJuggler::RTFQuery
- TaskJuggler::RTFReport
- TaskJuggler::RTFReportLink
- TaskJuggler::RTFWithQuerySupport
- TaskJuggler::RealFormat
- TaskJuggler::RealFormatAttribute
- TaskJuggler::ReferenceAttribute
- TaskJuggler::Report
- TaskJuggler::ReportBase
- TaskJuggler::ReportContext
- TaskJuggler::ReportScenario
- TaskJuggler::ReportServer
- TaskJuggler::ReportServerIface
- TaskJuggler::ReportServerRecord
- TaskJuggler::ReportServlet
- TaskJuggler::ReportTable
- TaskJuggler::ReportTableCell
- TaskJuggler::ReportTableColumn
- TaskJuggler::ReportTableLegend
- TaskJuggler::ReportTableLine
- TaskJuggler::Resource
- TaskJuggler::ResourceListAttribute
- TaskJuggler::ResourceListRE
- TaskJuggler::ResourceScenario
- TaskJuggler::RichText
- TaskJuggler::RichTextAttribute
- TaskJuggler::RichTextDocument
- TaskJuggler::RichTextElement
- TaskJuggler::RichTextFunctionExample
- TaskJuggler::RichTextFunctionHandler
- TaskJuggler::RichTextImage
- TaskJuggler::RichTextIntermediate
- TaskJuggler::RichTextParser
- TaskJuggler::RichTextScanner
- TaskJuggler::RichTextSnip
- TaskJuggler::RichTextSyntaxRules
- TaskJuggler::Scenario
- TaskJuggler::ScenarioData
- TaskJuggler::ScenarioListAttribute
- TaskJuggler::Scoreboard
- TaskJuggler::ScoreboardInterval
- TaskJuggler::SheetHandlerBase
- TaskJuggler::SheetReceiver
- TaskJuggler::SheetSender
- TaskJuggler::Shift
- TaskJuggler::ShiftAssignment
- TaskJuggler::ShiftAssignments
- TaskJuggler::ShiftAssignmentsAttribute
- TaskJuggler::ShiftScenario
- TaskJuggler::SimpleQueryExpander
- TaskJuggler::SortListAttribute
- TaskJuggler::StatusSheetReceiver
- TaskJuggler::StatusSheetReport
- TaskJuggler::StatusSheetSender
- TaskJuggler::StdIoWrapper
- TaskJuggler::StringAttribute
- TaskJuggler::SymbolAttribute
- TaskJuggler::SymbolListAttribute
- TaskJuggler::SyntaxReference
- TaskJuggler::TOCEntry
- TaskJuggler::TSResourceRecord
- TaskJuggler::TSTaskRecord
- TaskJuggler::TableColumnDefinition
- TaskJuggler::TableColumnSorter
- TaskJuggler::TableOfContents
- TaskJuggler::TableReport
- TaskJuggler::TableReportColumn
- TaskJuggler::TagFile
- TaskJuggler::TagFile::TagFileEntry
- TaskJuggler::Task
- TaskJuggler::TaskDepListAttribute
- TaskJuggler::TaskDependency
- TaskJuggler::TaskListAttribute
- TaskJuggler::TaskListRE
- TaskJuggler::TaskScenario
- TaskJuggler::TernarySearchTree
- TaskJuggler::TextFormatter
- TaskJuggler::TextParser
- TaskJuggler::TextParser::Macro
- TaskJuggler::TextParser::MacroTable
- TaskJuggler::TextParser::Pattern
- TaskJuggler::TextParser::Rule
- TaskJuggler::TextParser::Scanner
- TaskJuggler::TextParser::Scanner::BufferStreamHandle
- TaskJuggler::TextParser::Scanner::FileStreamHandle
- TaskJuggler::TextParser::Scanner::MacroStackEntry
- TaskJuggler::TextParser::Scanner::StreamHandle
- TaskJuggler::TextParser::SourceFileInfo
- TaskJuggler::TextParser::StackElement
- TaskJuggler::TextParser::State
- TaskJuggler::TextParser::StateTransition
- TaskJuggler::TextParser::TextParserResultArray
- TaskJuggler::TextParser::TokenDoc
- TaskJuggler::TextReport
- TaskJuggler::TimeInterval
- TaskJuggler::TimeIntervalListAttribute
- TaskJuggler::TimeSheet
- TaskJuggler::TimeSheetReceiver
- TaskJuggler::TimeSheetRecord
- TaskJuggler::TimeSheetReport
- TaskJuggler::TimeSheetSender
- TaskJuggler::TimeSheetSummary
- TaskJuggler::TimeSheets
- TaskJuggler::Tj3
- TaskJuggler::Tj3AppBase
- TaskJuggler::Tj3Client
- TaskJuggler::Tj3Daemon
- TaskJuggler::Tj3Man
- TaskJuggler::Tj3SheetAppBase
- TaskJuggler::Tj3SsReceiver
- TaskJuggler::Tj3SsSender
- TaskJuggler::Tj3TsReceiver
- TaskJuggler::Tj3TsSender
- TaskJuggler::Tj3TsSummary
- TaskJuggler::Tj3WebD
- TaskJuggler::TjException
- TaskJuggler::TjRuntimeError
- TaskJuggler::TjTime
- TaskJuggler::TjpExample
- TaskJuggler::TjpExportRE
- TaskJuggler::TjpSyntaxRules
- TaskJuggler::TraceReport
- TaskJuggler::URLParameter
- TaskJuggler::UserManual
- TaskJuggler::VimSyntax
- TaskJuggler::WebServer
- TaskJuggler::WelcomePage
- TaskJuggler::WorkingHours
- TaskJuggler::WorkingHoursAttribute
- TaskJuggler::XMLBlob
- TaskJuggler::XMLComment
- TaskJuggler::XMLDocument
- TaskJuggler::XMLElement
- TaskJuggler::XMLNamedText
- TaskJuggler::XMLText
- Diff
- Diff::Hunk
- AppConfig
- Diffable
- DiffableString
- Object
- RuntimeConfig
- String

No matching classes.

# TaskJuggler::Scoreboard

Scoreboard objects are instrumental during the scheduling process. The project time span is divided into discrete time slots by the scheduling resolution. This class models the resulting time slots with an array that spans from project start o project end. Each slot has an index start with 0 at the project start.

### Attributes

endDate[R]
resolution[R]
size[R]
startDate[R]

### Public Class Methods

new(startDate, endDate, resolution, initVal = nil) click to toggle source

Create the scoreboard based on the the given startDate, endDate and timing resolution. The resolution must be specified in seconds. Optionally you can provide an initial value for the scoreboard cells.

    # File lib/taskjuggler/Scoreboard.rb, line 28
    def initialize(startDate, endDate, resolution, initVal = nil)
      @startDate = startDate
      @endDate = endDate
      @resolution = resolution
      @size = ((endDate - startDate) / resolution).ceil + 1
      clear(initVal)
    end

### Public Instance Methods

[](idx) click to toggle source

Get the value at index idx.

    # File lib/taskjuggler/Scoreboard.rb, line 95
    def [](idx)
      @sb[idx]
    end

[]=(idx, value) click to toggle source

Set the value at index idx.

    # File lib/taskjuggler/Scoreboard.rb, line 100
    def []=(idx, value)
      @sb[idx] = value
    end

clear(initVal = nil) click to toggle source

Erase all values and set them to nil or a new initial value.

    # File lib/taskjuggler/Scoreboard.rb, line 37
    def clear(initVal = nil)
      @sb = Array.new(@size, initVal)
    end

collect!() click to toggle source

Assign result of block to each element.

    # File lib/taskjuggler/Scoreboard.rb, line 90
    def collect!
      @sb.collect! { |x| yield x }
    end

collectIntervals(iv, minDuration) click to toggle source

Return a list of intervals that describe a contiguous part of the scoreboard that contains only the values that yield true for the passed block. The intervals must be within the interval described by iv and must be at least minDuration long. The return value is an IntervalList.

    # File lib/taskjuggler/Scoreboard.rb, line 119
    def collectIntervals(iv, minDuration)
      # Determine the start and stop index for the scoreboard search. We save
      # the original values for later use as well.
      startIdx = sIdx = dateToIdx(iv.start)
      endIdx = eIdx = dateToIdx(iv.end)

      # Convert the minDuration into number of slots.
      minDuration /= @resolution
      minDuration = 1 if minDuration <= 0

      # Expand the interval with the minDuration to both sides. This will
      # reduce the failure to detect intervals at the iv boundary. However,
      # this will not prevent undetected intervals at the project time frame
      # boundaries.
      startIdx -= minDuration
      startIdx = 0 if startIdx < 0
      endIdx += minDuration
      endIdx = @size - 1 if endIdx > @size - 1

      # This is collects the resulting intervals.
      intervals = IntervalList.new

      # The duration counter for the currently analyzed interval and the start
      # index.
      duration = start = 0

      idx = startIdx
      loop do
        # Check whether the scoreboard slot matches any of the target values
        # and we have not yet reached the last slot.
        if yield(@sb[idx]) && idx < endIdx
          # If so, save the start position if this is the first slot and start
          # counting the matching slots.
          start = idx if start == 0
          duration += 1
        else
          # If we don't have a match or are at the end of the interval, check
          # if we've just finished a matching interval.
          if duration > 0
            if duration >= minDuration
              # Make sure that all intervals are within the originally
              # requested Interval.
              start = sIdx if start < sIdx
              idx = eIdx if idx > eIdx

              intervals << TimeInterval.new(idxToDate(start), idxToDate(idx))
            end
            duration = start = 0
          end
        end
        break if (idx += 1) > endIdx
      end

      intervals
    end

dateToIdx(date, forceIntoProject = true) click to toggle source

Converts a date to the corresponding scoreboard index. You can optionally sanitize the date by forcing it into the project time span.

    # File lib/taskjuggler/Scoreboard.rb, line 55
    def dateToIdx(date, forceIntoProject = true)
      idx = ((date - @startDate) / @resolution).to_i

      if forceIntoProject
        return 0 if idx < 0
        return @size - 1 if idx >= @size
      elsif (idx < 0 || idx >= @size)
        raise "Date #{date} is out of project time range " +
              "(#{@startDate} - #{@endDate})"
      end

      idx
    end

each(startIdx = 0, endIdx = @size) click to toggle source

Iterate over all scoreboard entries.

    # File lib/taskjuggler/Scoreboard.rb, line 70
    def each(startIdx = 0, endIdx = @size)
      if startIdx != 0 || endIdx != @size
        startIdx.upto(endIdx - 1) do |i|
          yield @sb[i]
        end
      else
        @sb.each do |entry|
          yield entry
        end
      end
    end

each_index() click to toggle source

Iterate over all scoreboard entries by index.

    # File lib/taskjuggler/Scoreboard.rb, line 83
    def each_index
      @sb.each_index do |index|
        yield index
      end
    end

get(date) click to toggle source

Get the value corresponding to date.

    # File lib/taskjuggler/Scoreboard.rb, line 105
    def get(date)
      @sb[dateToIdx(date)]
    end

idxToDate(idx, forceIntoProject = false) click to toggle source

Converts a scroreboard index to the corresponding date. You can optionally sanitize the idx value by forcing it into the project range.

    # File lib/taskjuggler/Scoreboard.rb, line 43
    def idxToDate(idx, forceIntoProject = false)
      if forceIntoProject
        return @startDate if kdx < 0
        return @endDate if @size - 1 if idx >= @size
      elsif idx < 0 || idx >= @size
        raise "Index #{idx} is out of scoreboard range (#{size - 1})"
      end
      @startDate + idx * @resolution
    end

inspect() click to toggle source

    # File lib/taskjuggler/Scoreboard.rb, line 175
    def inspect
      0.upto(@sb.length - 1) do |i|
        puts "#{idxToDate(i)}: #{@sb[i]}"
      end
    end

set(date, value) click to toggle source

Set the value corresponding to date.

    # File lib/taskjuggler/Scoreboard.rb, line 110
    def set(date, value)
      @sb[dateToIdx(date)] = value
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.