Sha256: 12e43fe1c2e14b8471f5dd89e5045561de2363ad7f1aafa9042d96635101eeae

Contents?: true

Size: 1.96 KB

Versions: 2

Compression:

Stored size: 1.96 KB

Contents

module Active
  module Services
    class Activity
      attr_accessor :title, :url, :category, :address, :start_date, :start_time, :end_time, :end_date, :category, :desc,
                    :asset_id, :data
      def initialize data
        @data      = HashWithIndifferentAccess.new(data)  
        self.title    = @data[:title]
        @url      = @data[:url]
  
        unless @data[:meta].nil?  
          self.asset_id                    = @data[:meta][:assetId]      
          @start_date                  = Date.parse(@data[:meta][:startDate])    
          @end_date                    = Date.parse(@data[:meta][:endDate])  if @data[:meta][:endDate]
          self.category                    = @data[:meta][:channel]      ||= ""
          
          @desc                        = @data[:meta][:description]  ||= ""
          @start_time                  = @data[:meta][:startTime]    ||= ""
          @end_time                    = @data[:meta][:endTime]      ||= ""
          @address = {
            :name    => @data[:meta][:locationName],
            :address    => @data[:meta][:location],
            :city    => @data[:meta][:city],
            :state   => @data[:meta][:state],
            :zip     => @data[:meta][:zip],
            :lat     => @data[:meta][:latitude],
            :lng     => @data[:meta][:longitude],
            :country => @data[:meta][:country]
            
            # dma?
            
          }
        end
        @onlineDonationAvailable     = @data[:meta][:onlineDonationAvailable]
        @onlineRegistrationAvailable = @data[:meta][:onlineRegistrationAvailable]
        @onlineMembershipAvailable   = @data[:meta][:onlineMembershipAvailable]

      end
      
      # ahhh... just use the first channel if it's an array.
      def category=(value)
        @category = (value.class == Array) ? value[0] : value
      end
      
      def asset_id=(value)        
        @asset_id = (value.class==Array) ? value[0] : value
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
Active-0.0.5 lib/services/activity.rb
Active-0.0.4 lib/services/activity.rb