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)


244
245
246
# File 'lib/actv/asset.rb', line 244

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

#attribute_pathsObject



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

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

#attributesObject



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

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

#awcamps30?Boolean

Returns:

  • (Boolean)


236
237
238
# File 'lib/actv/asset.rb', line 236

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

#awcamps?Boolean

Returns:

  • (Boolean)


232
233
234
# File 'lib/actv/asset.rb', line 232

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

#awendurance?Boolean

Returns:

  • (Boolean)


224
225
226
# File 'lib/actv/asset.rb', line 224

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

#awsports?Boolean

Returns:

  • (Boolean)


228
229
230
# File 'lib/actv/asset.rb', line 228

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

#channelsObject Also known as: asset_channels, assetChannels



100
101
102
103
104
# File 'lib/actv/asset.rb', line 100

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

#componentsObject Also known as: asset_components, assetComponents



124
125
126
127
128
# File 'lib/actv/asset.rb', line 124

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

#descriptionObject



160
161
162
# File 'lib/actv/asset.rb', line 160

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

#description_by_type(type) ⇒ Object



169
170
171
172
# File 'lib/actv/asset.rb', line 169

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



76
77
78
79
80
# File 'lib/actv/asset.rb', line 76

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

#endurance_idObject



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

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

#evergreen?Boolean

Returns:

  • (Boolean)


212
213
214
# File 'lib/actv/asset.rb', line 212

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

#first_topicObject Also known as: topic



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

def first_topic
  get_first_topic_taxonomy[0]
end

#first_topic_nameObject



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

def first_topic_name
  topics.first.topic.name unless topics.empty?
end

#first_topic_pathObject



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

def first_topic_path
  urlize first_topic
end

#has_location?Boolean

Returns:

  • (Boolean)


208
209
210
# File 'lib/actv/asset.rb', line 208

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

#imageObject



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

def image
  image_without_placeholder
end

#image_by_name(name) ⇒ Object



174
175
176
# File 'lib/actv/asset.rb', line 174

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

#image_pathObject



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

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



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

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



108
109
110
111
112
# File 'lib/actv/asset.rb', line 108

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

#is_article?Boolean

Returns:

  • (Boolean)


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

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)


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

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)


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

def kids?
  kids_friendly_source_system? && kids_interest?
end

#legacy_dataObject Also known as: asset_legacy_data, assetLegacyData



94
95
96
# File 'lib/actv/asset.rb', line 94

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

#location_pathObject



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

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

#media_urlObject



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

def media_url
  image_without_placeholder.imageUrlAdr rescue ""
end

#meta_interest_pathsObject



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

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

#meta_interestsObject



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

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

#org_timezoneObject



68
69
70
# File 'lib/actv/asset.rb', line 68

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

#placeObject



60
61
62
# File 'lib/actv/asset.rb', line 60

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

#place_timezoneObject



64
65
66
# File 'lib/actv/asset.rb', line 64

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

#pricesObject Also known as: asset_prices, assetPrices



132
133
134
135
136
# File 'lib/actv/asset.rb', line 132

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

#recurrencesObject



54
55
56
57
58
# File 'lib/actv/asset.rb', line 54

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

#regcenter2?Boolean

Returns:

  • (Boolean)


220
221
222
# File 'lib/actv/asset.rb', line 220

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

#regcenter?Boolean

Returns:

  • (Boolean)


216
217
218
# File 'lib/actv/asset.rb', line 216

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

#registration_statusObject Also known as: reg_status



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

def registration_status
  @registration_status ||= nil
end

#seo_url(systemName = 'as3') ⇒ Object



164
165
166
167
# File 'lib/actv/asset.rb', line 164

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



148
149
150
151
152
# File 'lib/actv/asset.rb', line 148

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



84
85
86
# File 'lib/actv/asset.rb', line 84

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

#sub_2_topicObject



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

def sub_2_topic
  get_first_topic_taxonomy[2]
end

#sub_2_topic_pathObject



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

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

#sub_3_topicObject



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

def sub_3_topic
  get_first_topic_taxonomy[3]
end

#sub_3_topic_pathObject



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

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

#sub_4_topicObject



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

def sub_4_topic
  get_first_topic_taxonomy[4]
end

#sub_4_topic_pathObject



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

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

#sub_topicObject



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

def sub_topic
  get_first_topic_taxonomy[1]
end

#sub_topic_pathObject



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

def sub_topic_path
  urlize sub_topic
end

#summaryObject



156
157
158
# File 'lib/actv/asset.rb', line 156

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

#tag_by_description(description) ⇒ Object



178
179
180
181
# File 'lib/actv/asset.rb', line 178

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



116
117
118
119
120
# File 'lib/actv/asset.rb', line 116

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

#thriva?Boolean

Returns:

  • (Boolean)


240
241
242
# File 'lib/actv/asset.rb', line 240

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

#topicsObject Also known as: asset_topics, assetTopics



140
141
142
143
144
# File 'lib/actv/asset.rb', line 140

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

#versionObject



72
73
74
# File 'lib/actv/asset.rb', line 72

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

#visible?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/actv/asset.rb', line 90

def visible?
  asset_status.visible?
end