Class: Record
- Inherits:
-
Object
- Object
- Record
- Defined in:
- lib/log_analysis/model/record.rb
Constant Summary collapse
- DATA_TYPE =
%w[.txt .json .js .css .jpg .jpeg .gif .woff2 .ico .png .bmp .mp3 .wav .avi .mpeg .vmw .mpg .map .pdf .doc .svg .otf].freeze
- REGEX_BOT =
/facebookexternalhit|Mediapartners-Google|AWS|-|Crawler|spider|Detection/.freeze
Instance Attribute Summary collapse
-
#apptime ⇒ Object
Returns the value of attribute apptime.
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#forwardedfor ⇒ Object
Returns the value of attribute forwardedfor.
-
#forwardedproto ⇒ Object
Returns the value of attribute forwardedproto.
-
#host ⇒ Object
Returns the value of attribute host.
-
#method ⇒ Object
Returns the value of attribute method.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#referer ⇒ Object
Returns the value of attribute referer.
-
#req ⇒ Object
Returns the value of attribute req.
-
#reqtime ⇒ Object
Returns the value of attribute reqtime.
-
#request_length ⇒ Object
Returns the value of attribute request_length.
-
#runtime ⇒ Object
Returns the value of attribute runtime.
-
#size ⇒ Object
Returns the value of attribute size.
-
#status ⇒ Object
Returns the value of attribute status.
-
#time ⇒ Object
Returns the value of attribute time.
-
#ua ⇒ Object
Returns the value of attribute ua.
-
#uri ⇒ Object
Returns the value of attribute uri.
-
#user ⇒ Object
Returns the value of attribute user.
-
#vhost ⇒ Object
Returns the value of attribute vhost.
Instance Method Summary collapse
-
#initialize(params) ⇒ Record
constructor
A new instance of Record.
- #method_get? ⇒ Boolean
- #robot? ⇒ Boolean
- #status_200? ⇒ Boolean
- #uri_without_data ⇒ Object
Constructor Details
#initialize(params) ⇒ Record
Returns a new instance of Record.
31 32 33 34 |
# File 'lib/log_analysis/model/record.rb', line 31 def initialize(params) @params = params record_params.keys.each { |key| instance_variable_set("@#{key}", record_params[key]) } end |
Instance Attribute Details
#apptime ⇒ Object
Returns the value of attribute apptime.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def apptime @apptime end |
#cache ⇒ Object
Returns the value of attribute cache.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def cache @cache end |
#forwardedfor ⇒ Object
Returns the value of attribute forwardedfor.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def forwardedfor @forwardedfor end |
#forwardedproto ⇒ Object
Returns the value of attribute forwardedproto.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def forwardedproto @forwardedproto end |
#host ⇒ Object
Returns the value of attribute host.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def host @host end |
#method ⇒ Object
Returns the value of attribute method.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def method @method end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
26 27 28 |
# File 'lib/log_analysis/model/record.rb', line 26 def params @params end |
#referer ⇒ Object
Returns the value of attribute referer.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def referer @referer end |
#req ⇒ Object
Returns the value of attribute req.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def req @req end |
#reqtime ⇒ Object
Returns the value of attribute reqtime.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def reqtime @reqtime end |
#request_length ⇒ Object
Returns the value of attribute request_length.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def request_length @request_length end |
#runtime ⇒ Object
Returns the value of attribute runtime.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def runtime @runtime end |
#size ⇒ Object
Returns the value of attribute size.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def size @size end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def status @status end |
#time ⇒ Object
Returns the value of attribute time.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def time @time end |
#ua ⇒ Object
Returns the value of attribute ua.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def ua @ua end |
#uri ⇒ Object
Returns the value of attribute uri.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def uri @uri end |
#user ⇒ Object
Returns the value of attribute user.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def user @user end |
#vhost ⇒ Object
Returns the value of attribute vhost.
7 8 9 |
# File 'lib/log_analysis/model/record.rb', line 7 def vhost @vhost end |
Instance Method Details
#method_get? ⇒ Boolean
40 41 42 |
# File 'lib/log_analysis/model/record.rb', line 40 def method_get? method == 'GET' end |
#robot? ⇒ Boolean
50 51 52 |
# File 'lib/log_analysis/model/record.rb', line 50 def robot? ua.bot? || ua.to_s.match?(REGEX_BOT) end |
#status_200? ⇒ Boolean
36 37 38 |
# File 'lib/log_analysis/model/record.rb', line 36 def status_200? status == 200 end |
#uri_without_data ⇒ Object
44 45 46 47 48 |
# File 'lib/log_analysis/model/record.rb', line 44 def uri_without_data return false if uri.nil? || uri.end_with?(*DATA_TYPE) true end |