lib/simple_log_counter/parser.rb
# Parses web log file to dicionary of page counts.
#
# Algorithm centres around a reduction operation, so time complexity =
# O(n)
Parses web log file to dicionary of page counts.
Algorithm centres around a reduction operation, so time complexity
O(n)
Parses web log file to dicionary of page counts . Algorithm centres around a reduction operation so time complexity O ( n )
def parse(log, unique: false)
        page_count_pairs = if unique
                             unique_visitor_counter(log)
                           else
                             visitor_counter(log)
                           end
        Hash[page_count_pairs.sort_by { |_, n| -n }]
      end
def parse ( log , unique : false ) page_count_pairs = if unique unique_visitor_counter ( log ) else visitor_counter ( log ) end Hash [ page_count_pairs . sort_by { | _ , n | - n } ] end
Parses web log file to dicionary of page counts.
Parses web log file to dicionary of page counts .
# Convert back to hash and sort in descending order.
log
unique