Class: Squiggle::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/squiggle/base.rb

Direct Known Subclasses

SquidStandardParser

Instance Method Summary collapse

Constructor Details

#initialize(time_zone) ⇒ Base

Returns a new instance of Base.



4
5
6
# File 'lib/squiggle/base.rb', line 4

def initialize(time_zone)
  @time_zone = time_zone
end

Instance Method Details

#cached?(logline) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/squiggle/base.rb', line 26

def cached?(logline)
  # TODO Implement this
  false
end

#pageview?(logline) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
# File 'lib/squiggle/base.rb', line 19

def pageview?(logline)
  case logline.mime_type
    when /html/,/text/,/pdf/ then true
    else false
  end
end

#parse(line) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/squiggle/base.rb', line 8

def parse(line)
  logline = process(line)
  if logline.valid?
    logline.cached = cached?(logline)
    logline.pageview = pageview?(logline)
  else
    #STDERR.puts("INVALID LINE (#{logline.errors}): '#{line}'") unless line.blank?
  end
  logline
end

#parse_timestamp(str) ⇒ Object

Return the time in the client’s time zone



32
33
34
35
36
37
38
# File 'lib/squiggle/base.rb', line 32

def parse_timestamp(str)
  # Parses the timestamp into localtime
  t = Time.at(str.gsub(/^L/, '').to_i)
  # TODO: Right now this will only work with the NFAgent - can't be used on the server as we can't translate to an arbitrary TZ
  # Return the time zone in the clients TZ
  # t.in_time_zone(@time_zone)
end