lib/m3u8/media_item.rb in m3u8-0.5.3 vs lib/m3u8/media_item.rb in m3u8-0.6.1

- old
+ new

@@ -1,29 +1,29 @@ module M3u8 # MediaItem represents a set of EXT-X-MEDIA attributes class MediaItem - include M3u8 + extend M3u8 attr_accessor :type, :group_id, :language, :assoc_language, :name, :autoselect, :default, :uri, :forced def initialize(params = {}) params.each do |key, value| instance_variable_set("@#{key}", value) end end - def parse(text) + def self.parse(text) attributes = parse_attributes text options = { type: attributes['TYPE'], group_id: attributes['GROUP-ID'], language: attributes['LANGUAGE'], assoc_language: attributes['ASSOC-LANGUAGE'], name: attributes['NAME'], autoselect: parse_yes_no(attributes['AUTOSELECT']), default: parse_yes_no(attributes['DEFAULT']), forced: parse_yes_no(attributes['FORCED']), uri: attributes['URI'] } - initialize options + MediaItem.new options end def to_s attributes = [type_format, group_id_format, @@ -80,9 +80,9 @@ return if forced.nil? "FORCED=#{to_yes_no forced}" end def to_yes_no(boolean) - boolean == true ? 'YES' : 'NO' + boolean == true ? 'YES' : 'NO' end end end