Class: PodcastFeedGen::Episode
- Inherits:
-
Object
- Object
- PodcastFeedGen::Episode
- Defined in:
- lib/podcast_feed_gen/episode.rb
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(path, config) ⇒ Episode
constructor
A new instance of Episode.
Constructor Details
#initialize(path, config) ⇒ Episode
Returns a new instance of Episode.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/podcast_feed_gen/episode.rb', line 9 def initialize(path, config) @config = config filename = File.basename path ext = File.extname path TagLib::FileRef.open(path) do |fileref| t = fileref.tag p = fileref.audio_properties nilify = ->(s){ s == "" ? nil : s } @values = { filename: filename, title: nilify[t.title] || filename, author: nilify[t.artist], description: nilify[t.comment] || filename, duration: duration(p.length), date: File.mtime(path), size: File.size(path), mime_type: Generator::FILETYPES[ext], sha256: Digest::SHA256.hexdigest(File.read(path)), url: @config[:base_url] + filename }.freeze end end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
7 8 9 |
# File 'lib/podcast_feed_gen/episode.rb', line 7 def values @values end |
Instance Method Details
#[](key) ⇒ Object
36 37 38 |
# File 'lib/podcast_feed_gen/episode.rb', line 36 def [](key) @values[key] end |