Class: UR::Product::DistributionEvent
- Inherits:
-
Object
- Object
- UR::Product::DistributionEvent
- Defined in:
- lib/ur/product/distribution_event.rb
Instance Attribute Summary collapse
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#event_type ⇒ Object
readonly
Returns the value of attribute event_type.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#receiving_agent_group ⇒ Object
readonly
Returns the value of attribute receiving_agent_group.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #in_the_future? ⇒ Boolean
-
#initialize(data) ⇒ DistributionEvent
constructor
A new instance of DistributionEvent.
- #translated_platform ⇒ Object
Constructor Details
#initialize(data) ⇒ DistributionEvent
Returns a new instance of DistributionEvent.
7 8 9 10 11 12 13 |
# File 'lib/ur/product/distribution_event.rb', line 7 def initialize(data) @start_date = Time.parse(data['startdate']) if !data['startdate'].nil? @end_date = Time.parse(data['enddate']) if !data['enddate'].nil? @receiving_agent_group = data['receivingagentgroup'] @platform = data['platform'] @event_type = data['type'] end |
Instance Attribute Details
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
4 5 6 |
# File 'lib/ur/product/distribution_event.rb', line 4 def end_date @end_date end |
#event_type ⇒ Object (readonly)
Returns the value of attribute event_type.
4 5 6 |
# File 'lib/ur/product/distribution_event.rb', line 4 def event_type @event_type end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
4 5 6 |
# File 'lib/ur/product/distribution_event.rb', line 4 def platform @platform end |
#receiving_agent_group ⇒ Object (readonly)
Returns the value of attribute receiving_agent_group.
4 5 6 |
# File 'lib/ur/product/distribution_event.rb', line 4 def receiving_agent_group @receiving_agent_group end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
4 5 6 |
# File 'lib/ur/product/distribution_event.rb', line 4 def start_date @start_date end |
Instance Method Details
#active? ⇒ Boolean
15 16 17 |
# File 'lib/ur/product/distribution_event.rb', line 15 def active? (start_date < Time.now && end_date > Time.now) ? true : false end |
#in_the_future? ⇒ Boolean
19 20 21 |
# File 'lib/ur/product/distribution_event.rb', line 19 def in_the_future? Time.now < @start_date end |
#translated_platform ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ur/product/distribution_event.rb', line 23 def translated_platform translations = { 'dab' => 'Digital radio', 'internet' => 'Webben', 'k' => 'Kunskapskanalen', 'p1' => 'P1', 'p2' => 'P2', 'p3' => 'P3', 'p4' => 'P4', 'svt1' => 'SVT 1', 'svt2' => 'SVT 2', 'svtb' => 'Barnkanalen' } translations.has_key?(platform) ? translations[platform] : platform end |