Class: RTunesU::Track
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
Attributes inherited from Entity
#connection, #handle, #parent, #parent_handle, #saved, #source_xml
Class Method Summary collapse
-
.find(handle, group_handle, connection = nil) ⇒ Object
Tracks can only be found from within their Course.
Instance Method Summary collapse
Methods inherited from Entity
attributes, base_connection, #base_connection, base_connection=, #class_name, composed_of, #edited?, #edits, get_base_connection, #handle_from_source, has_a, has_n, #initialize, #inspect, #reload, set_base_connection, #to_xml, validates!, #value_from_edits_or_store
Constructor Details
This class inherits a constructor from RTunesU::Entity
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
3 4 5 |
# File 'lib/rtunesu/entities/track.rb', line 3 def file @file end |
Class Method Details
.find(handle, group_handle, connection = nil) ⇒ Object
Tracks can only be found from within their Course. There is currently (v1.1.3) no way to find a Track separete from its Course in iTunes U.
32 33 34 35 36 37 38 39 |
# File 'lib/rtunesu/entities/track.rb', line 32 def self.find(handle, group_handle, connection = nil) connection ||= self.base_connection track = self.new track.instance_variable_set('@handle', handle) track.source_xml = Group.find(group_handle, connection).source_xml.at("Track/Handle[text()=#{handle}]/..") track end |
Instance Method Details
#create(connection = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rtunesu/entities/track.rb', line 13 def create(connection = nil) connection ||= self.base_connection if file response = connection.upload_file(file, self.parent_handle, false) @parent_handle, @handle = response.split('.')[-2..-1] self.source_xml = Group.find(@parent_handle, connection).source_xml.at("Track/Handle[text()=#{@handle}]/..") self else super end end |
#update(connection = nil) ⇒ Object
25 26 27 28 |
# File 'lib/rtunesu/entities/track.rb', line 25 def update(connection = nil) raise "Cannot save existing Track with new file attached. Delete the old track and create a new one instead." if file super end |