Class: BBC::Programmes::Version
- Inherits:
-
Base
- Object
- Base
- BBC::Programmes::Version
show all
- Defined in:
- lib/bbc/programmes/version.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
fetch, #fetch!, #pid, subclasses
Class Method Details
.id_for(identifier) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/bbc/programmes/version.rb', line 14
def self.id_for(identifier)
if identifier.is_a?(::String)
super(
RDF::URI("#{base_uri}/#{identifier}#programme")
)
else
super(identifier)
end
end
|
Instance Method Details
#broadcasts ⇒ Object
24
25
26
27
28
29
|
# File 'lib/bbc/programmes/version.rb', line 24
def broadcasts
Broadcast.repository.query([nil, RDF::PO.broadcast_of, subject]).map do |b|
b.subject.as(Broadcast)
end
end
|
#intervals ⇒ Object
35
36
37
38
39
|
# File 'lib/bbc/programmes/version.rb', line 35
def intervals
TimeInterval.repository.query([nil, RDF::TimeLine.timeline, timeline.subject]).map do |b|
b.subject.as(TimeInterval)
end
end
|
#segments ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/bbc/programmes/version.rb', line 41
def segments
intervals = self.intervals.select {|i| !i.position.nil?}
intervals.sort! {|a,b| (a.position.to_i||0) <=> (b.position.to_i||0)}
intervals.map do |interval|
segment = Segment.repository.first_subject([nil, RDF::PO.time, interval.subject])
segment.nil? ? nil : segment.as(Segment)
end
end
|
#timeline ⇒ Object
31
32
33
|
# File 'lib/bbc/programmes/version.rb', line 31
def timeline
time.nil? ? nil : time.timeline
end
|