Class: MythTV::Recording
- Inherits:
-
Object
- Object
- MythTV::Recording
- Defined in:
- lib/mythtv/recording.rb
Constant Summary collapse
- RECORDINGS_ELEMENTS =
Represents a recording that is held on the MythTV Backend server we are communicating with.
The keys included here, and the order in which they are specified seem to change between protocol version bumps on the MythTV backend, so this array affects both the initialize() and to_s() methods.
Found inside mythtv/libs/libmythtv/programinfo.cpp in the MythTV subversion repository
[ :title, :subtitle, :description, :category, :chanid, :chanstr, :chansign, :channame, :pathname, :filesize_hi, :filesize_lo, :startts, :endts, :duplicate, :shareable, :findid, :hostname, :sourceid, :cardid, :inputid, :recpriority, :recstatus, :recordid, :rectype, :dupin, :dupmethod, :recstartts, :recendts, :repeat, :programflags, :recgroup, :chancommfree, :chanOutputFilters, :seriesid, :programid, :lastmodified, :stars, :originalAirDate, :hasAirDate, :playgroup, :recpriority2, :parentid, :storagegroup, :audioproperties, :videoproperties, :subtitleType ]
Instance Method Summary collapse
- #duration ⇒ Object
- #end ⇒ Object
-
#filename ⇒ Object
Strip the filename out from the path returned by the server.
-
#filesize ⇒ Object
Convert the lo/hi long representation of the filesize into a string.
-
#initialize(recording_array) ⇒ Recording
constructor
Warning, metaprogramming ahead: Create attr_accessors for each symbol defined in MythTVRecording::RECORDINGS_ELEMENTS.
-
#myth_delimited_recstart ⇒ Object
Cribbed from the Mythweb PHP code.
-
#myth_nondelimited_recstart ⇒ Object
Formats the start time for use in the copy process, as the latter half of the filename is a non-delimited time string.
-
#path ⇒ Object
Fetch the path section of the pathname.
-
#start ⇒ Object
Convenience methods to access the start and end times as Time objects, and duration as an Float.
-
#to_s ⇒ Object
A string representation of a Recording is used when we converse with the MythTV Backend about that recording.
Constructor Details
#initialize(recording_array) ⇒ Recording
Warning, metaprogramming ahead: Create attr_accessors for each symbol defined in MythTVRecording::RECORDINGS_ELEMENTS
19 20 21 22 23 24 25 |
# File 'lib/mythtv/recording.rb', line 19 def initialize(recording_array) class << self;self;end.class_eval { RECORDINGS_ELEMENTS.each { |field| attr_accessor field } } RECORDINGS_ELEMENTS.each_with_index do |field, i| send(field.to_s + '=', recording_array[i]) end end |
Instance Method Details
#duration ⇒ Object
35 |
# File 'lib/mythtv/recording.rb', line 35 def duration; self.end - self.start; end |
#end ⇒ Object
34 |
# File 'lib/mythtv/recording.rb', line 34 def end; Time.at(recendts.to_i); end |
#filename ⇒ Object
Strip the filename out from the path returned by the server
52 |
# File 'lib/mythtv/recording.rb', line 52 def filename; File.basename(URI.parse(pathname).path); end |
#filesize ⇒ Object
Convert the lo/hi long representation of the filesize into a string
44 45 46 |
# File 'lib/mythtv/recording.rb', line 44 def filesize [filesize_lo.to_i, filesize_hi.to_i].pack("ll").unpack("Q").to_s end |
#myth_delimited_recstart ⇒ Object
Cribbed from the Mythweb PHP code. Required for some method calls to the backend
38 |
# File 'lib/mythtv/recording.rb', line 38 def myth_delimited_recstart; myth_format_time(recstartts, :delimited); end |
#myth_nondelimited_recstart ⇒ Object
Formats the start time for use in the copy process, as the latter half of the filename is a non-delimited time string
41 |
# File 'lib/mythtv/recording.rb', line 41 def myth_nondelimited_recstart; myth_format_time(recstartts, :nondelimited); end |
#path ⇒ Object
Fetch the path section of the pathname
49 |
# File 'lib/mythtv/recording.rb', line 49 def path; URI.parse(pathname).path; end |
#start ⇒ Object
Convenience methods to access the start and end times as Time objects, and duration as an Float
33 |
# File 'lib/mythtv/recording.rb', line 33 def start; Time.at(recstartts.to_i); end |
#to_s ⇒ Object
A string representation of a Recording is used when we converse with the MythTV Backend about that recording
28 29 30 |
# File 'lib/mythtv/recording.rb', line 28 def to_s RECORDINGS_ELEMENTS.collect { |field| self.send(field.to_s) }.join(MythTV::Backend::FIELD_SEPARATOR) + MythTV::Backend::FIELD_SEPARATOR end |