Sha256: a879590f9a586caccfd17b7bee35e03be4ab99fcbffda722f787ea1f5428b2d0

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

# encoding: UTF-8

require_relative '../attributes/attributes'
require_relative '../metadata/column'
require_relative '../references/references'

module GoodData
  module Model
    ##
    # Date column. A container holding the following
    # parts: date fact, a date reference or attribute and an optional time component
    # that contains a time fact and a time reference or attribute.
    #
    class DateColumn < Column
      attr_reader :parts, :facts, :attributes, :references

      def initialize(column, schema)
        super column, schema
        @parts = {}
        @facts = []
        @attributes = []
        @references = []

        # @facts << @parts[:date_fact] = DateFact.new(column, schema)
        if column[:dataset]
          @parts[:date_ref] = DateReference.new column, schema
          @references << @parts[:date_ref]
        else
          @attributes << @parts[:date_attr] = DateAttribute.new(column, schema)
        end
        # if column['datetime'] then
        #   puts "*** datetime"
        #   @facts << @parts[:time_fact] = TimeFact.new(column, schema)
        #   if column['schema_reference'] then
        #     @parts[:time_ref] = TimeReference.new column, schema
        #   else
        #     @attributes << @parts[:time_attr] = TimeAttribute.new(column, schema)
        #   end
        # end
      end

      def to_maql_create
        @parts.values.map { |v| v.to_maql_create }.join "\n"
      end

      def to_maql_drop
        @parts.values.map { |v| v.to_maql_drop }.join "\n"
      end

      def to_csv_header(row)
        SKIP_FIELD
      end

      def to_csv_data(headers, row)
        SKIP_FIELD
      end

      def to_manifest_part(mode)
        nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gooddata-0.6.4 lib/gooddata/models/columns/date_column.rb
gooddata-0.6.3 lib/gooddata/models/columns/date_column.rb
gooddata-0.6.2 lib/gooddata/models/columns/date_column.rb