Class: UR::Product::DistributionEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/ur/product/distribution_event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_dateObject (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_typeObject (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

#platformObject (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_groupObject (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_dateObject (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

Returns:

  • (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

Returns:

  • (Boolean)


19
20
21
# File 'lib/ur/product/distribution_event.rb', line 19

def in_the_future?
  Time.now < @start_date
end

#translated_platformObject



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