Class: ACTV::Asset

Inherits:
Identity show all
Defined in:
lib/actv/asset.rb

Direct Known Subclasses

Article, Event

Instance Attribute Summary collapse

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Identity

#==, #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: end_date, activity_end_date

Returns the value of attribute activityEndDate.



18
19
20
# File 'lib/actv/asset.rb', line 18

def activityEndDate
  @activityEndDate
end

#activityEndTimeObject (readonly) Also known as: end_time

Returns the value of attribute activityEndTime.



18
19
20
# File 'lib/actv/asset.rb', line 18

def activityEndTime
  @activityEndTime
end

#activityStartDateObject (readonly) Also known as: start_date, activity_start_date

Returns the value of attribute activityStartDate.



18
19
20
# File 'lib/actv/asset.rb', line 18

def activityStartDate
  @activityStartDate
end

#activityStartTimeObject (readonly) Also known as: start_time

Returns the value of attribute activityStartTime.



18
19
20
# File 'lib/actv/asset.rb', line 18

def activityStartTime
  @activityStartTime
end

#assetDscObject (readonly)

Returns the value of attribute assetDsc.



18
19
20
# File 'lib/actv/asset.rb', line 18

def assetDsc
  @assetDsc
end

#assetGuidObject (readonly) Also known as: id

Returns the value of attribute assetGuid.



18
19
20
# File 'lib/actv/asset.rb', line 18

def assetGuid
  @assetGuid
end

#assetNameObject (readonly) Also known as: title

Returns the value of attribute assetName.



18
19
20
# File 'lib/actv/asset.rb', line 18

def assetName
  @assetName
end

#authorNameObject (readonly) Also known as: author_name

Returns the value of attribute authorName.



18
19
20
# File 'lib/actv/asset.rb', line 18

def authorName
  @authorName
end

#contactEmailAdrObject (readonly) Also known as: contact_email

Returns the value of attribute contactEmailAdr.



18
19
20
# File 'lib/actv/asset.rb', line 18

def contactEmailAdr
  @contactEmailAdr
end

#contactNameObject (readonly) Also known as: contact_name

Returns the value of attribute contactName.



18
19
20
# File 'lib/actv/asset.rb', line 18

def contactName
  @contactName
end

#contactPhoneObject (readonly) Also known as: contact_phone

Returns the value of attribute contactPhone.



18
19
20
# File 'lib/actv/asset.rb', line 18

def contactPhone
  @contactPhone
end

#contactTxtObject (readonly) Also known as: contact_txt

Returns the value of attribute contactTxt.



18
19
20
# File 'lib/actv/asset.rb', line 18

def contactTxt
  @contactTxt
end

#createdDateObject (readonly) Also known as: created_at

Returns the value of attribute createdDate.



18
19
20
# File 'lib/actv/asset.rb', line 18

def createdDate
  @createdDate
end

#currencyCdObject (readonly) Also known as: currency_code

Returns the value of attribute currencyCd.



18
19
20
# File 'lib/actv/asset.rb', line 18

def currencyCd
  @currencyCd
end

#homePageUrlAdrObject (readonly) Also known as: home_page_url

Returns the value of attribute homePageUrlAdr.



18
19
20
# File 'lib/actv/asset.rb', line 18

def homePageUrlAdr
  @homePageUrlAdr
end

#is_articleObject (readonly)

Returns the value of attribute is_article.



18
19
20
# File 'lib/actv/asset.rb', line 18

def is_article
  @is_article
end

#is_eventObject (readonly)

Returns the value of attribute is_event.



18
19
20
# File 'lib/actv/asset.rb', line 18

def is_event
  @is_event
end

#isRecurringObject (readonly) Also known as: is_recurring?

Returns the value of attribute isRecurring.



18
19
20
# File 'lib/actv/asset.rb', line 18

def isRecurring
  @isRecurring
end

#modifiedDateObject (readonly) Also known as: updated_at

Returns the value of attribute modifiedDate.



18
19
20
# File 'lib/actv/asset.rb', line 18

def modifiedDate
  @modifiedDate
end

#publishDateObject (readonly) Also known as: published_at

Returns the value of attribute publishDate.



18
19
20
# File 'lib/actv/asset.rb', line 18

def publishDate
  @publishDate
end

#regReqGenderCdObject (readonly) Also known as: required_gender

Returns the value of attribute regReqGenderCd.



18
19
20
# File 'lib/actv/asset.rb', line 18

def regReqGenderCd
  @regReqGenderCd
end

#regReqMaxAgeObject (readonly) Also known as: maximum_age

Returns the value of attribute regReqMaxAge.



18
19
20
# File 'lib/actv/asset.rb', line 18

def regReqMaxAge
  @regReqMaxAge
end

#regReqMinAgeObject (readonly) Also known as: minimum_age

Returns the value of attribute regReqMinAge.



18
19
20
# File 'lib/actv/asset.rb', line 18

def regReqMinAge
  @regReqMinAge
end

#showContactObject (readonly) Also known as: show_contact?

Returns the value of attribute showContact.



18
19
20
# File 'lib/actv/asset.rb', line 18

def showContact
  @showContact
end

Instance Method Details

#activenet?Boolean

Returns:

  • (Boolean)


242
243
244
# File 'lib/actv/asset.rb', line 242

def activenet?
  self.sourceSystem[:legacyGuid].upcase == "FB27C928-54DB-4ECD-B42F-482FC3C8681F" rescue false
end

#attribute_pathsObject



264
265
266
267
268
# File 'lib/actv/asset.rb', line 264

def attribute_paths
  attributes.map do |attribute|
    [sub_topic_path, urlize(attribute)].join "/"
  end
end

#attributesObject



256
257
258
259
260
261
262
# File 'lib/actv/asset.rb', line 256

def attributes
  @attributes ||= assetAttributes.sort_by do |attribute|
    attribute[:attribute][:attributeType]
  end.map do |attribute|
    attribute[:attribute][:attributeValue]
  end
end

#awcamps30?Boolean

Returns:

  • (Boolean)


234
235
236
# File 'lib/actv/asset.rb', line 234

def awcamps30?
  self.sourceSystem[:legacyGuid].upcase == "89208DBA-F535-4950-880A-34A6888A184C" rescue false
end

#awcamps?Boolean

Returns:

  • (Boolean)


230
231
232
# File 'lib/actv/asset.rb', line 230

def awcamps?
  self.sourceSystem[:legacyGuid].upcase == "2B22B4E6-5AA4-44D7-BF06-F7A71F9FA8A6" rescue false
end

#awendurance?Boolean

Returns:

  • (Boolean)


222
223
224
# File 'lib/actv/asset.rb', line 222

def awendurance?
  self.sourceSystem[:legacyGuid].upcase == "DFAA997A-D591-44CA-9FB7-BF4A4C8984F1" rescue false
end

#awsports?Boolean

Returns:

  • (Boolean)


226
227
228
# File 'lib/actv/asset.rb', line 226

def awsports?
  self.sourceSystem[:legacyGuid].upcase == "F036B0FF-2B21-43A9-8C20-7F447D3AB105" rescue false
end

#channelsObject Also known as: asset_channels, assetChannels



98
99
100
101
102
# File 'lib/actv/asset.rb', line 98

def channels
  @asset_channels ||= Array(@attrs[:assetChannels]).map do |channel|
    ACTV::AssetChannel.new(channel)
  end
end

#componentsObject Also known as: asset_components, assetComponents



122
123
124
125
126
# File 'lib/actv/asset.rb', line 122

def components
  @asset_components ||= Array(@attrs[:assetComponents]).map do |component|
    ACTV::AssetComponent.new(component)
  end
end

#descriptionObject



158
159
160
# File 'lib/actv/asset.rb', line 158

def description
  @description ||= description_by_type 'Standard'
end

#description_by_type(type) ⇒ Object



167
168
169
170
# File 'lib/actv/asset.rb', line 167

def description_by_type(type)
  dsc = self.descriptions.find { |dsc| dsc.type.name.downcase == type.downcase }
  (dsc.description.downcase == 'n/a' ? '' : dsc.description) if dsc
end

#descriptionsObject Also known as: asset_descriptions, assetDescriptions



74
75
76
77
78
# File 'lib/actv/asset.rb', line 74

def descriptions
  @descriptions ||= Array(@attrs[:assetDescriptions]).map do |description|
    ACTV::AssetDescription.new(description)
  end
end

#endurance_idObject



46
47
48
49
50
# File 'lib/actv/asset.rb', line 46

def endurance_id
  if self.awendurance?
    Addressable::URI.parse(registrationUrlAdr.to_s).query_values.to_h.fetch 'e', nil
  end
end

#evergreen?Boolean

Returns:

  • (Boolean)


210
211
212
# File 'lib/actv/asset.rb', line 210

def evergreen?
  self.evergreenAssetFlag.downcase == 'true' rescue false
end

#first_topicObject Also known as: topic



288
289
290
# File 'lib/actv/asset.rb', line 288

def first_topic
  get_first_topic_taxonomy[0]
end

#first_topic_nameObject



297
298
299
# File 'lib/actv/asset.rb', line 297

def first_topic_name
  topics.first.topic.name
end

#first_topic_pathObject



293
294
295
# File 'lib/actv/asset.rb', line 293

def first_topic_path
  urlize first_topic
end

#has_location?Boolean

Returns:

  • (Boolean)


206
207
208
# File 'lib/actv/asset.rb', line 206

def has_location?
  self.place && place.has_lat_long?
end

#imageObject



356
357
358
# File 'lib/actv/asset.rb', line 356

def image
  image_without_placeholder
end

#image_by_name(name) ⇒ Object



172
173
174
# File 'lib/actv/asset.rb', line 172

def image_by_name(name)
  self.images.find { |img| img.name.downcase == name.downcase }
end

#image_pathObject



341
342
343
344
345
346
347
348
349
350
# File 'lib/actv/asset.rb', line 341

def image_path
  default_image = 'http://www.active.com/images/events/hotrace.gif'
  image = image_without_placeholder.imageUrlAdr rescue ""

  if image.empty? and (logoUrlAdr && logoUrlAdr != default_image && !(logoUrlAdr =~ URI::regexp).nil?)
      image = logoUrlAdr
  end

  image
end

#image_with_placeholderObject



333
334
335
336
337
338
339
# File 'lib/actv/asset.rb', line 333

def image_with_placeholder
  if image_path.empty?
    "/images/logo-active-icon-gray.gif"
  else
    image_path
  end
end

#imagesObject Also known as: asset_images, assetImages



106
107
108
109
110
# File 'lib/actv/asset.rb', line 106

def images
  @images ||= Array(@attrs[:assetImages]).map do |img|
    ACTV::AssetImage.new(img)
  end
end

#is_article?Boolean

Returns:

  • (Boolean)


190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/actv/asset.rb', line 190

def is_article?
  is_article = false
  if self.assetCategories.any?
    self.assetCategories.each do |category|
      if category[:category][:categoryName].downcase == 'articles'
        is_article = true
      end
    end
  else
    # no categories so check the sourceSystem
    is_article = articles_source?
  end

  is_article
end

#is_event?Boolean

Returns:

  • (Boolean)


181
182
183
184
185
186
187
188
# File 'lib/actv/asset.rb', line 181

def is_event?
  self.assetCategories.each do |category|
    if category[:category][:categoryTaxonomy].downcase.start_with?('event')
      return true
    end
  end
  false
end

#kids?Boolean

Returns:

  • (Boolean)


246
247
248
249
# File 'lib/actv/asset.rb', line 246

def kids?
  return false if Rails.env == 'production'
   kids_friendly_source_system? && kids_interest?
end

#legacy_dataObject Also known as: asset_legacy_data, assetLegacyData



92
93
94
# File 'lib/actv/asset.rb', line 92

def legacy_data
  @legacy_data ||= ACTV::AssetLegacyData.new(@attrs[:assetLegacyData]) unless @attrs[:assetLegacyData].nil?
end

#location_pathObject



284
285
286
# File 'lib/actv/asset.rb', line 284

def location_path
  @location ||= "#{place.cityName} #{place.stateProvinceCode}".downcase.gsub ' ','-'
end

#media_urlObject



352
353
354
# File 'lib/actv/asset.rb', line 352

def media_url
  image_without_placeholder.imageUrlAdr rescue ""
end

#meta_interest_pathsObject



278
279
280
281
282
# File 'lib/actv/asset.rb', line 278

def meta_interest_paths
  meta_interests.map do |meta_interest|
    [sub_topic_path, urlize(meta_interest)].join "/"
  end
end

#meta_interestsObject



270
271
272
273
274
275
276
# File 'lib/actv/asset.rb', line 270

def meta_interests
  @meta_interests ||= attrs[:assetMetaInterests].sort_by do |interest|
    interest[:sequence]
  end.map do |interest|
    interest[:metaInterest][:metaInterestName]
  end
end

#org_timezoneObject



66
67
68
# File 'lib/actv/asset.rb', line 66

def org_timezone
  @org_timezone ||= @attrs[:localTimeZoneId] unless @attrs[:localTimeZoneId].nil?
end

#placeObject



58
59
60
# File 'lib/actv/asset.rb', line 58

def place
  @place ||= ACTV::Place.new(@attrs[:place]) unless @attrs[:place].nil?
end

#place_timezoneObject



62
63
64
# File 'lib/actv/asset.rb', line 62

def place_timezone
  @place_timezone ||= place[:timezone] unless place[:timezone].nil?
end

#pricesObject Also known as: asset_prices, assetPrices



130
131
132
133
134
# File 'lib/actv/asset.rb', line 130

def prices
  @asset_prices ||= Array(@attrs[:assetPrices]).map do |price|
    ACTV::AssetPrice.new(price)
  end
end

#recurrencesObject



52
53
54
55
56
# File 'lib/actv/asset.rb', line 52

def recurrences
  @recurrences ||= Array(@attrs[:activityRecurrences]).map do | recurrence |
    ACTV::Recurrence.new(recurrence)
  end
end

#regcenter2?Boolean

Returns:

  • (Boolean)


218
219
220
# File 'lib/actv/asset.rb', line 218

def regcenter2?
  self.sourceSystem[:legacyGuid].upcase == "3BF82BBE-CF88-4E8C-A56F-78F5CE87E4C6" rescue false
end

#regcenter?Boolean

Returns:

  • (Boolean)


214
215
216
# File 'lib/actv/asset.rb', line 214

def regcenter?
  self.sourceSystem[:legacyGuid].upcase == "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65" rescue false
end

#registration_statusObject Also known as: reg_status



251
252
253
# File 'lib/actv/asset.rb', line 251

def registration_status
  @registration_status ||= nil
end

#seo_url(systemName = 'as3') ⇒ Object



162
163
164
165
# File 'lib/actv/asset.rb', line 162

def seo_url(systemName = 'as3')
  seo_url = self.seo_urls.find { |s| s.seoSystemName.downcase == systemName.downcase }
  seo_url.urlAdr unless seo_url.nil?
end

#seo_urlsObject Also known as: asset_seo_urls, assetSeoUrls



146
147
148
149
150
# File 'lib/actv/asset.rb', line 146

def seo_urls
  @seo_urls ||= Array(@attrs[:assetSeoUrls]).map do |seo_url|
    ACTV::AssetSeoUrl.new(seo_url)
  end
end

#statusObject Also known as: asset_status, assetStatus



82
83
84
# File 'lib/actv/asset.rb', line 82

def status
  @status ||= ACTV::AssetStatus.new(@attrs[:assetStatus]) unless @attrs[:assetStatus].nil?
end

#sub_2_topicObject



309
310
311
# File 'lib/actv/asset.rb', line 309

def sub_2_topic
  get_first_topic_taxonomy[2]
end

#sub_2_topic_pathObject



313
314
315
# File 'lib/actv/asset.rb', line 313

def sub_2_topic_path
  urlize "#{sub_topic_path}/#{sub_2_topic}"
end

#sub_3_topicObject



317
318
319
# File 'lib/actv/asset.rb', line 317

def sub_3_topic
  get_first_topic_taxonomy[3]
end

#sub_3_topic_pathObject



321
322
323
# File 'lib/actv/asset.rb', line 321

def sub_3_topic_path
  urlize "#{sub_2_topic_path}/#{sub_3_topic}"
end

#sub_4_topicObject



325
326
327
# File 'lib/actv/asset.rb', line 325

def sub_4_topic
  get_first_topic_taxonomy[4]
end

#sub_4_topic_pathObject



329
330
331
# File 'lib/actv/asset.rb', line 329

def sub_4_topic_path
  urlize "#{sub_3_topic_path}/#{sub_4_topic}"
end

#sub_topicObject



301
302
303
# File 'lib/actv/asset.rb', line 301

def sub_topic
  get_first_topic_taxonomy[1]
end

#sub_topic_pathObject



305
306
307
# File 'lib/actv/asset.rb', line 305

def sub_topic_path
  urlize sub_topic
end

#summaryObject



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

def summary
  @summary ||= description_by_type 'summary'
end

#tag_by_description(description) ⇒ Object



176
177
178
179
# File 'lib/actv/asset.rb', line 176

def tag_by_description(description)
  asset_tag = self.tags.find { |at| at.tag.description.downcase == description.downcase }
  asset_tag.tag.name if asset_tag
end

#tagsObject Also known as: asset_tags, assetTags



114
115
116
117
118
# File 'lib/actv/asset.rb', line 114

def tags
  @asset_tags ||= Array(@attrs[:assetTags]).map do |tag|
    ACTV::AssetTag.new(tag)
  end
end

#thriva?Boolean

Returns:

  • (Boolean)


238
239
240
# File 'lib/actv/asset.rb', line 238

def thriva?
  self.sourceSystem[:legacyGuid].upcase == "2BA50ABA-080E-4E3D-A01C-1B4F56648A2E" rescue false
end

#topicsObject Also known as: asset_topics, assetTopics



138
139
140
141
142
# File 'lib/actv/asset.rb', line 138

def topics
  @asset_topics ||= Array(@attrs[:assetTopics]).map do |topic|
    ACTV::AssetTopic.new(topic)
  end.sort
end

#versionObject



70
71
72
# File 'lib/actv/asset.rb', line 70

def version
  @asset_version ||= @attrs[:assetVersion] unless @attrs[:assetVersion].nil?
end

#visible?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/actv/asset.rb', line 88

def visible?
  asset_status.visible?
end