Sha256: 49efdad4e1c07bdede7fc3dda7b26408a783b6d2e5bc70aaef756e3072d9e1e9

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require 'duration'
require 'time'

module MPXJ
  # Base class from which all project entities are derived
  class Container
    attr_reader :parent_project
    def initialize(parent_project, attribute_values)
      @parent_project = parent_project
      @attribute_values = attribute_values
    end

    attr_reader :attribute_values

    private

    def get_duration_value(attribute_value)
      if attribute_value.nil?
        Duration.new(0)
      else
        Duration.new(attribute_value.to_i)
      end
    end

    def get_date_value(attribute_value)
      if attribute_value.nil?
        nil
      else
        @parent_project.zone.parse(attribute_value)
      end
    end

    def get_float_value(attribute_value)
      if attribute_value.nil?
        0.0
      else
        attribute_value.to_f
      end
    end

    def get_integer_value(attribute_value)
      if attribute_value.nil?
        0
      else
        attribute_value.to_i
      end
    end

    def get_boolean_value(attribute_value)
      attribute_value == true
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mpxj-9.6.0 lib/mpxj/container.rb
mpxj-9.5.2 lib/mpxj/container.rb
mpxj-9.5.1 lib/mpxj/container.rb
mpxj-9.5.0 lib/mpxj/container.rb