Class: ACTV::Event

Inherits:
Asset show all
Defined in:
lib/actv/event.rb

Constant Summary

Constants included from AssetSourceSystem

AssetSourceSystem::SOURCE_SYSTEM_HASH

Instance Attribute Summary collapse

Attributes inherited from Asset

#activityEndTime, #activityStartTime, #assetDsc, #assetGuid, #assetName, #authorName, #contactEmailAdr, #contactName, #contactPhone, #contactTxt, #createdDate, #currencyCd, #homePageUrlAdr, #isRecurring, #is_article, #is_event, #modifiedDate, #publishDate, #regReqGenderCd, #regReqMaxAge, #regReqMinAge, #showContact

Attributes inherited from Base

#attrs

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Asset

#attribute_paths, #attributes, #category_is?, #channels, #components, #description, #description_by_type, #descriptions, #endurance_id, #evergreen?, #first_topic, #first_topic_name, #first_topic_path, from_response, #has_location?, #has_volume_based_price?, #image, #image_by_name, #image_path, #image_with_placeholder, #images, inherited, #initialize, #is_article?, #is_video?, #kids?, #legacy_data, #location_path, #media_url, #meta_interest_paths, #meta_interests, #org_timezone, #organization, #place, #place_timezone, #prices, #recurrences, #references, #registration_status, #seo_url, #seo_urls, #sponsored?, #status, #sub_2_topic, #sub_2_topic_path, #sub_3_topic, #sub_3_topic_path, #sub_4_topic, #sub_4_topic_path, #sub_topic, #sub_topic_path, #summary, #tag_by_description, #tags, #topics, types, #version, #visible?

Methods included from AssetSourceSystem

#kids_friendly_source_system?

Methods inherited from Identity

#==, #id, #initialize

Methods inherited from Base

#[], attr_reader, define_attribute_method, define_predicate_method, define_uri_method, #delete, from_response, #initialize, #memoize, #method_missing, object_attr_reader, #respond_to?, #to_hash, #update, uri_attr_reader

Constructor Details

This class inherits a constructor from ACTV::Asset

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ACTV::Base

Instance Attribute Details

#activityEndDateObject (readonly)

Returns the value of attribute activityEndDate.



5
6
7
# File 'lib/actv/event.rb', line 5

def activityEndDate
  @activityEndDate
end

#activityStartDateObject (readonly)

Returns the value of attribute activityStartDate.



5
6
7
# File 'lib/actv/event.rb', line 5

def activityStartDate
  @activityStartDate
end

#salesEndDateObject (readonly) Also known as: sales_end_date

Returns the value of attribute salesEndDate.



5
6
7
# File 'lib/actv/event.rb', line 5

def salesEndDate
  @salesEndDate
end

#salesStartDateObject (readonly) Also known as: sales_start_date

Returns the value of attribute salesStartDate.



5
6
7
# File 'lib/actv/event.rb', line 5

def salesStartDate
  @salesStartDate
end

Class Method Details

.valid?(response) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/actv/event.rb', line 9

def self.valid? response
  ACTV::EventValidator.new(response).valid?
end

Instance Method Details

#course_mapObject



13
14
15
# File 'lib/actv/event.rb', line 13

def course_map
  @course_map ||= tag_by_description 'coursemap'
end

#display_close_dateObject Also known as: display_close_date?



89
90
91
92
93
94
95
96
97
98
# File 'lib/actv/event.rb', line 89

def display_close_date
  @display_close_date ||= begin
    val = tag_by_description 'displayclosedate'
    if val
      val.downcase == 'true'
    else
      true
    end
  end
end

#event_end_dateObject

Returns the asset’s end date in UTC. This is pulled from the activityEndDate.



123
124
125
# File 'lib/actv/event.rb', line 123

def event_end_date
  Time.parse "#{activity_end_date} #{format_timezone_offset(timezone_offset)}"
end

#event_ended?Boolean Also known as: ended?

Returns:

  • (Boolean)


53
54
55
56
57
# File 'lib/actv/event.rb', line 53

def event_ended?
  if is_present? activity_end_date
    is_now_after? "#{activity_end_date.split('T').first}T23:59:59"
  end
end

#event_start_dateObject

Returns the asset’s start date in UTC. This is pulled from the activityStartDate.



117
118
119
# File 'lib/actv/event.rb', line 117

def event_start_date
  Time.parse "#{activity_start_date} #{format_timezone_offset(timezone_offset)}"
end

#image_urlObject



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/actv/event.rb', line 131

def image_url
  defaultImage = 'https://www.active.com/images/events/hotrace.gif'
  image = ''

  self.assetImages.each do |i|
    if i.imageUrlAdr.downcase != defaultImage
      image = i.imageUrlAdr
      break
    end
  end

  if image.blank?
    if (self.logoUrlAdr && self.logoUrlAdr != defaultImage && self.logoUrlAdr =~ URI::regexp)
      image = self.logoUrlAdr
    end
  end
  image
end

#is_event?Boolean

Returns:

  • (Boolean)


150
151
152
# File 'lib/actv/event.rb', line 150

def is_event?
  true
end

#online_registration_available?Boolean Also known as: online_registration?

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/actv/event.rb', line 17

def online_registration_available?
  if is_present?(self.registrationUrlAdr)
    if is_present?(self.legacy_data) && is_present?(self.legacy_data.onlineRegistration.to_s)
      self.legacy_data.onlineRegistration.to_s.downcase == 'true'
    else
      true
    end
  else
    false
  end
end

#registration_close_dateObject

Returns the asset’s registration end date in UTC. This is pulled from the salesEndDate



111
112
113
# File 'lib/actv/event.rb', line 111

def registration_close_date
  Time.parse "#{authoritative_reg_end_date} UTC"
end

#registration_closed?Boolean Also known as: reg_closed?

Returns:

  • (Boolean)


37
38
39
40
41
42
43
# File 'lib/actv/event.rb', line 37

def registration_closed?
  if online_registration_available?
    is_now_after? authoritative_reg_end_date
  else
    false
  end
end

#registration_closing_soon?(time_in_days = 3) ⇒ Boolean

Returns:

  • (Boolean)


74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/actv/event.rb', line 74

def registration_closing_soon?(time_in_days=3)
  @reg_closing_soon ||= begin
    if online_registration_available?
      if self.sales_end_date
        if now_in_utc >= utc_time(self.sales_end_date) - time_in_days.days and
          now_in_utc < utc_time(self.end_date)
          return true
        end
      end
    end

    false
  end
end

#registration_not_yet_open?Boolean Also known as: registration_not_open?, reg_not_open?, reg_not_yet_open?

Returns:

  • (Boolean)


45
46
47
48
49
50
51
# File 'lib/actv/event.rb', line 45

def registration_not_yet_open?
  if online_registration_available?
    is_now_before? authoritative_reg_start_date
  else
    false
  end
end

#registration_open?Boolean Also known as: reg_open?

Returns:

  • (Boolean)


29
30
31
32
33
34
35
# File 'lib/actv/event.rb', line 29

def registration_open?
  if online_registration_available?
    is_now_between? authoritative_reg_start_date, authoritative_reg_end_date
  else
    false
  end
end

#registration_open_dateObject

Returns the asset’s registration open date in UTC. This is pulled from the salesStartDate



105
106
107
# File 'lib/actv/event.rb', line 105

def registration_open_date
  Time.parse "#{authoritative_reg_start_date} UTC"
end

#registration_opening_soon?(time_in_days = 3) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/actv/event.rb', line 59

def registration_opening_soon?(time_in_days=3)
  @reg_open_soon ||= begin
    if online_registration_available?
      if self.sales_start_date
        if now_in_utc >= utc_time(self.sales_start_date) - time_in_days.days and
          now_in_utc < utc_time(self.sales_start_date)
          return true
        end
      end
    end

    false
  end
end

#timezone_offsetObject



127
128
129
# File 'lib/actv/event.rb', line 127

def timezone_offset
  place.timezoneOffset + place.timezoneDST
end

#videoObject



154
155
156
# File 'lib/actv/event.rb', line 154

def video
  self.images.detect { |i| i.video? }
end