Sha256: 5497be5ff9e3190a0d39b3c2009b6f3a48013e00304e97e5b90d5fe1996bd625

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

module MPXJ
  # Represents a calendar exception
  class CalendarException < Container
    attr_reader :hours

    def initialize(parent_project, attribute_values)
      super(parent_project, attribute_values.slice('name', 'from', 'to', 'type'))
      process_hours(attribute_values)
    end

    # Retrieve the exception name
    #
    # @return [String] the exception name
    def name
      attribute_values['name']
    end

    # Retrieve the date on which this exception starts
    #
    # @return [Time] the exception from date
    def from
      get_date_value(attribute_values['from'])
    end

    # Retrieve the date on which this exception ends
    #
    # @return [Time] the exception to date
    def to
      get_date_value(attribute_values['to'])
    end

    # Retrieve the exception type
    #
    # @return [String] the exception type
    def type
      attribute_values['type']
    end

    private

    def process_hours(attribute_values)
      @hours = (attribute_values['hours'] || {}).map do |hours|
        CalendarHours.new(parent_project, hours)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mpxj-13.10.0 lib/mpxj/calendar_exception.rb
mpxj-13.9.0 lib/mpxj/calendar_exception.rb
mpxj-13.8.0 lib/mpxj/calendar_exception.rb
mpxj-13.7.0 lib/mpxj/calendar_exception.rb