Sha256: 570e2266b8dc7a0bbd2874e3e6f13951e69e59207e654138f87f7cc53fcef432

Contents?: true

Size: 774 Bytes

Versions: 3

Compression:

Stored size: 774 Bytes

Contents

require 'date'
require 'time'

module SparkApi
  module Models
    class OpenHouse < Base
      extend Subresource

      self.element_name = "openhouses"
      
      def initialize(attributes={})
        # Transform the date strings
        unless attributes['Date'].nil?
          date = Date.parse(attributes['Date'])
          attributes['Date'] = date
          attributes['StartTime'] = Time.parse("#{date}T#{attributes['StartTime']}") unless attributes['StartTime'].nil?
          attributes['EndTime'] = Time.parse("#{date}T#{attributes['EndTime']}") unless attributes['EndTime'].nil?
        end
        
        if attributes["Comments"].nil?
          attributes["Comments"] = ""
        end
        
        super(attributes)
      end
      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spark_api-1.1.0 lib/spark_api/models/open_house.rb
spark_api-1.0.4 lib/spark_api/models/open_house.rb
spark_api-1.0.2 lib/spark_api/models/open_house.rb