Sha256: e0c81b0d804bd62117bddccbac8ca8912e740eb525d3dc7f3ff2f3b4128bab9a

Contents?: true

Size: 797 Bytes

Versions: 4

Compression:

Stored size: 797 Bytes

Contents

# frozen_string_literal: true
require 'bigdecimal'
require 'stringio'
Dir[File.dirname(__FILE__) + '/m3u8/*.rb'].sort.each { |file| require file }

# M3u8 provides parsing, generation, and validation of m3u8 playlists
module M3u8
  def intialize_with_byterange(params = {})
    params.each do |key, value|
      value = ByteRange.new(value) if value.is_a?(Hash)
      instance_variable_set("@#{key}", value)
    end
  end

  def parse_attributes(line)
    array = line.delete("\n").scan(/([A-z0-9-]+)\s*=\s*("[^"]*"|[^,]*)/)
    Hash[array.map { |key, value| [key, value.delete('"')] }]
  end

  def parse_float(value)
    value.nil? ? nil : value.to_f
  end

  def parse_yes_no(value)
    value == 'YES' ? true : false
  end

  def to_yes_no(boolean)
    boolean == true ? 'YES' : 'NO'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
m3u8-0.8.2 lib/m3u8.rb
m3u8-0.8.1 lib/m3u8.rb
m3u8-0.8.0 lib/m3u8.rb
m3u8-0.7.1 lib/m3u8.rb