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?, #image, #image_by_name, #image_path, #image_with_placeholder, #images, inherited, #is_article?, #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, #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::Identity

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

#display_close_dateObject Also known as: display_close_date?



85
86
87
88
89
90
91
92
93
94
# File 'lib/actv/event.rb', line 85

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.



119
120
121
# File 'lib/actv/event.rb', line 119

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

#event_ended?Boolean Also known as: ended?

Returns:

  • (Boolean)


49
50
51
52
53
# File 'lib/actv/event.rb', line 49

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.



113
114
115
# File 'lib/actv/event.rb', line 113

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

#image_urlObject



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/actv/event.rb', line 127

def image_url
  defaultImage = 'http://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)


146
147
148
# File 'lib/actv/event.rb', line 146

def is_event?
  true
end

#online_registration_available?Boolean Also known as: online_registration?

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/actv/event.rb', line 13

def online_registration_available?
  if is_present?(self.registrationUrlAdr)
    if is_present?(self.legacy_data) && is_present?(self.legacy_data.onlineRegistration)
      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



107
108
109
# File 'lib/actv/event.rb', line 107

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

#registration_closed?Boolean Also known as: reg_closed?

Returns:

  • (Boolean)


33
34
35
36
37
38
39
# File 'lib/actv/event.rb', line 33

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)


70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/actv/event.rb', line 70

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)


41
42
43
44
45
46
47
# File 'lib/actv/event.rb', line 41

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)


25
26
27
28
29
30
31
# File 'lib/actv/event.rb', line 25

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



101
102
103
# File 'lib/actv/event.rb', line 101

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

#registration_opening_soon?(time_in_days = 3) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/actv/event.rb', line 55

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



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

def timezone_offset
  place.timezoneOffset + place.timezoneDST
end

#videoObject



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

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