lib/feedjira/podcast/item/optional.rb in feedjira-podcast-0.9.8 vs lib/feedjira/podcast/item/optional.rb in feedjira-podcast-0.9.9

- old
+ new

@@ -1,10 +1,25 @@ module Feedjira module Podcast module Item module Optional + module InstanceMethods + def categories + category.map(&:strip).uniq + end + + def enclosure + @enclosure ||= Struct.new(:url, :length, :type).new( + enclosure_url, + enclosure_length, + enclosure_type, + ) + end + end + def self.included(base) + base.include(InstanceMethods) base.element :link do |link| Addressable::URI.parse(link) end @@ -14,32 +29,18 @@ base.element :comments do |comments| Addressable::URI.parse(comments) end - def categories - category.map{|c|c.strip}.uniq - end - base.element :enclosure, as: :enclosure_url, value: :url do |url| Addressable::URI.parse(url) end - base.element :enclosure, as: :enclosure_length, value: :length do |length| - length.to_f - end + base.element :enclosure, as: :enclosure_length, value: :length, &:to_f base.element :enclosure, as: :enclosure_type, value: :type - def enclosure - @enclosure ||= Struct.new(:url, :length, :type).new( - enclosure_url, - enclosure_length, - enclosure_type, - ) - end - base.element :guid, as: :guid, class: GUID, default: Struct.new(:guid, :perma_link?).new base.element :pubDate, as: :pub_date do |date| begin Time.parse(date) @@ -47,10 +48,9 @@ nil end end base.element :source, class: Source, default: Struct.new(:name, :url).new - end end end end end