ur-product 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,26 @@ module UR
15
15
  def active?
16
16
  (start_date < Time.now && end_date > Time.now) ? true : false
17
17
  end
18
+
19
+ def in_the_future?
20
+ Time.now < @start_date
21
+ end
22
+
23
+ def translated_platform
24
+ translations = {
25
+ 'dab' => 'Digital radio',
26
+ 'internet' => 'Webben',
27
+ 'k' => 'Kunskapskanalen',
28
+ 'p1' => 'P1',
29
+ 'p2' => 'P2',
30
+ 'p3' => 'P3',
31
+ 'p4' => 'P4',
32
+ 'svt1' => 'SVT 1',
33
+ 'svt2' => 'SVT 2',
34
+ 'svtb' => 'Barnkanalen'
35
+ }
36
+ translations.has_key?(platform) ? translations[platform] : platform
37
+ end
18
38
  end
19
39
  end
20
40
  end
data/lib/ur/product.rb CHANGED
@@ -19,20 +19,25 @@ module UR
19
19
  :sli, :sli_sub, :sab, :sao, :related_product_ids
20
20
 
21
21
  def initialize(data)
22
- product_data = data.include?('product') ? data['product'] : data
23
- relations = data.include?('relations') ? data['relations'] : []
24
- populate(product_data, relations)
25
-
26
- self.class.define_boolean_methods([
27
- 'distribution_events', 'storages', 'typical_age_ranges', 'languages',
28
- 'duration', 'difficulty', 'producing_company', 'production_year',
29
- 'obsolete_order_id', 'sli', 'sli_sub', 'sab', 'sao'
30
- ])
31
- self.class.define_relation_boolean_methods([
32
- 'siblings', 'packageseries', 'packageusageseries', 'website',
33
- 'packagedvd', 'packagecd', 'programtv', 'programradio',
34
- 'trailertrailer'
35
- ])
22
+ unless !data['status'].nil? && data['status'] == 404
23
+ product_data = data.include?('product') ? data['product'] : data
24
+ relations = data.include?('relations') ? data['relations'] : []
25
+ populate(product_data, relations)
26
+
27
+ self.class.define_boolean_methods([
28
+ 'distribution_events', 'storages', 'typical_age_ranges', 'languages',
29
+ 'duration', 'difficulty', 'producing_company', 'production_year',
30
+ 'obsolete_order_id', 'sli', 'sli_sub', 'sab', 'sao'
31
+ ])
32
+ self.class.define_relation_boolean_methods([
33
+ 'siblings', 'packageseries', 'packageusageseries', 'website',
34
+ 'packagedvd', 'packagecd', 'programtv', 'programradio',
35
+ 'trailertrailer'
36
+ ])
37
+ def ok?; true; end
38
+ else
39
+ def ok?; false; end
40
+ end
36
41
  end
37
42
 
38
43
  def self.find(id)
@@ -160,6 +165,18 @@ module UR
160
165
  @available_on_avc
161
166
  end
162
167
 
168
+ def broadcasts
169
+ return @broadcasts unless @broadcasts.nil?
170
+ @broadcasts = []
171
+
172
+ distribution_events.each do |event|
173
+ @broadcasts << event if event.event_type == 'broadcast'
174
+ end
175
+
176
+ @broadcasts = @broadcasts.sort_by { |broadcast| broadcast.start_date }
177
+ @broadcasts
178
+ end
179
+
163
180
  def documents
164
181
  return @docs unless @docs.nil?
165
182
  @docs = []
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ur-product
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 51
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 3
10
- version: 0.9.3
9
+ - 4
10
+ version: 0.9.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Peter Hellberg
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-18 00:00:00 +02:00
18
+ date: 2010-06-21 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency