Class: TivoHMO::Adapters::Filesystem::FileItem

Inherits:
Object
  • Object
show all
Includes:
GemLogger::LoggerSupport, TivoHMO::API::Item
Defined in:
lib/tivohmo/adapters/filesystem/file_item.rb

Overview

An Item based on a filesystem file

Instance Attribute Summary

Attributes included from TivoHMO::API::Item

#file, #subtitle

Attributes included from TivoHMO::API::Node

#app, #children, #content_type, #created_at, #identifier, #modified_at, #parent, #root, #source_format, #title

Instance Method Summary collapse

Methods included from TivoHMO::API::Item

#metadata, #to_s, #transcoder

Methods included from TivoHMO::API::Node

#add_child, #app?, #find, #root?, #title_path, #to_s, #tree_string

Constructor Details

#initialize(identifier, subtitle = nil) ⇒ FileItem

Returns a new instance of FileItem.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tivohmo/adapters/filesystem/file_item.rb', line 12

def initialize(identifier, subtitle=nil)
  full_path = File.expand_path(identifier)
  raise ArgumentError, "Must provide an existing file" unless File.file?(full_path)

  super(full_path)

  self.file = full_path
  self.subtitle = subtitle
  self.title = File.basename(self.identifier)
  self.title = "[#{subtitle.language_code} #{subtitle.type} sub] #{self.title}" if subtitle
  self.modified_at = File.mtime(self.identifier)
  self.created_at = File.ctime(self.identifier)
end