Class: ACTV::Evergreen
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ACTV::Evergreen
- Defined in:
- lib/actv/evergreen.rb
Instance Attribute Summary collapse
-
#asset ⇒ Object
Returns the value of attribute asset.
-
#current_event ⇒ Object
Returns the value of attribute current_event.
-
#events ⇒ Object
Returns the value of attribute events.
Instance Method Summary collapse
- #components ⇒ Object
- #description_by_type(type) ⇒ Object
- #evergreen? ⇒ Boolean
-
#initialize(asset) ⇒ Evergreen
constructor
A new instance of Evergreen.
- #legacy_data ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(asset) ⇒ Evergreen
Returns a new instance of Evergreen.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/actv/evergreen.rb', line 7 def initialize asset super asset @asset = asset @events = [] @current_event = {} asset.evergreenAssets.each do |sub_asset| @events << SubEvent.new(sub_asset) @current_event = sub_asset if Time.parse(sub_asset.fetch(:activityEndDate, "1970-01-01T00:00:01")) > Time.parse(@current_event.fetch(:activityEndDate, "1970-01-01T00:00:01")) end @events = @events.sort_by { |event| event.end_date }.reverse @current_event = ACTV.event @current_event[:assetGuid] self end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/actv/evergreen.rb', line 44 def method_missing method, *args, &block begin @asset.send(method, *args) rescue NoMethodError => e @current_event.send(method, *args) end end |
Instance Attribute Details
#asset ⇒ Object
Returns the value of attribute asset.
5 6 7 |
# File 'lib/actv/evergreen.rb', line 5 def asset @asset end |
#current_event ⇒ Object
Returns the value of attribute current_event.
5 6 7 |
# File 'lib/actv/evergreen.rb', line 5 def current_event @current_event end |
#events ⇒ Object
Returns the value of attribute events.
5 6 7 |
# File 'lib/actv/evergreen.rb', line 5 def events @events end |
Instance Method Details
#components ⇒ Object
26 27 28 |
# File 'lib/actv/evergreen.rb', line 26 def components @current_event.components end |
#description_by_type(type) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/actv/evergreen.rb', line 34 def description_by_type type asset_description = @asset.description_by_type type rescue nil if asset_description.present? asset_description else @current_event.description_by_type type end end |
#evergreen? ⇒ Boolean
22 23 24 |
# File 'lib/actv/evergreen.rb', line 22 def evergreen? true end |
#legacy_data ⇒ Object
30 31 32 |
# File 'lib/actv/evergreen.rb', line 30 def legacy_data @current_event.legacy_data end |