lib/parsers/ogg_parser.rb
# Returns granule_position of the last valid Ogg page contained in the given
# tail. Since the tail may contain multiple "OggS" entries the method searches
# them recursively starting from the end. The search stops when the first
# valid Oggs page is found.
#
# The granule position contains the offset of the page in terms of the
# number of samples from the start of file. So once we know that number
# we can estimate how long the file is. We _do_ need to add the number
# of samples the granule covers though
Returns granule_position of the last valid Ogg page contained in the given
tail. Since the tail may contain multiple "OggS" entries the method searches
them recursively starting from the end. The search stops when the first
valid Oggs page is found.

The granule position contains the offset of the page in terms of the
number of samples from the start of file. So once we know that number
we can estimate how long the file is. We _do_ need to add the number
of samples the granule covers though
Returns granule_position of the last valid Ogg page contained in the given tail . Since the tail may contain multiple " OggS " entries the method searches them recursively starting from the end . The search stops when the first valid Oggs page is found . The granule position contains the offset of the page in terms of the number of samples from the start of file . So once we know that number we can estimate how long the file is . We _do_ need to add the number of samples the granule covers though
def find_last_granule_position(in_string)
    rev_indices = all_indices_of_substr_in_str('OggS', in_string).reverse
    rev_indices.each do |idx|
      if granule_pos = extract_granule_position_from_string_at(in_string, idx)
        return granule_pos
      end
    end
    nil 
  end
def find_last_granule_position ( in_string ) rev_indices = all_indices_of_substr_in_str ( 'OggS' , in_string ) . reverse rev_indices . each do | idx | if granule_pos = extract_granule_position_from_string_at ( in_string , idx ) return granule_pos end end nil end
Returns granule_position of the last valid Ogg page contained in the given
tail.
Returns granule_position of the last valid Ogg page contained in the given tail .
# The Ogg page always starts with "OggS". Find all of them # in the given tail, since we want to scan "tail to head" - # starting with the last index and going down to the first # Nothing matched or the list of indices was empty
in_string