Class: ACTV::Event

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

Instance Attribute Summary collapse

Attributes inherited from Asset

#activityEndTime, #activityStartTime, #assetDsc, #assetGuid, #assetName, #authorName, #contactEmailAdr, #contactName, #contactPhone, #createdDate, #homePageUrlAdr, #isRecurring, #is_article, #is_event, #modifiedDate, #publishDate, #showContact

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Asset

#channels, #components, #description, #description_by_type, #descriptions, #evergreen?, #image_by_name, #images, #is_article?, #is_event?, #legacy_data, #place, #place_timezone, #prices, #registration_status, #seo_url, #seo_urls, #status, #summary, #tag_by_description, #tags, #topics

Methods inherited from Identity

#==, #id, #initialize

Methods inherited from Base

#[], attr_reader, define_attribute_method, define_predicate_method, define_uri_method, from_response, #initialize, #memoize, #method_missing, object_attr_reader, #respond_to?, #to_hash, 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) Also known as: activity_end_date

Returns the value of attribute activityEndDate.



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

def activityEndDate
  @activityEndDate
end

#activityStartDateObject (readonly) Also known as: activity_start_date

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

Instance Method Details

#display_close_dateObject Also known as: display_close_date?



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

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.



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

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

#event_ended?Boolean Also known as: ended?

Returns:

  • (Boolean)


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

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.



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

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

#online_registration_available?Boolean Also known as: online_registration?

Returns:

  • (Boolean)


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

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.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



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

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

#registration_closed?Boolean Also known as: reg_closed?

Returns:

  • (Boolean)


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

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)


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

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)


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

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)


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

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



99
100
101
# File 'lib/actv/event.rb', line 99

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

#registration_opening_soon?(time_in_days = 3) ⇒ Boolean

Returns:

  • (Boolean)


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

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



121
122
123
# File 'lib/actv/event.rb', line 121

def timezone_offset
  place.timezoneOffset + place.timezoneDST
end