Class: HTTPLogAnalyzer::Entry
- Inherits:
-
Object
- Object
- HTTPLogAnalyzer::Entry
- Defined in:
- lib/http-log-analyzer/entry.rb
Instance Attribute Summary collapse
-
#referer ⇒ Object
Returns the value of attribute referer.
-
#request ⇒ Object
Returns the value of attribute request.
-
#source ⇒ Object
Returns the value of attribute source.
-
#status ⇒ Object
Returns the value of attribute status.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
- #calendar_week ⇒ Object
-
#initialize(info) ⇒ Entry
constructor
A new instance of Entry.
Constructor Details
#initialize(info) ⇒ Entry
Returns a new instance of Entry.
12 13 14 15 16 17 18 19 20 |
# File 'lib/http-log-analyzer/entry.rb', line 12 def initialize(info) # 12/Feb/2016:09:59:04 +0000 @timestamp = DateTime.strptime(info[:datetime], '%d/%b/%Y:%H:%M:%S %Z') @source = Element::Source.parse(info[:ip]) @request = Element::Request.parse(info[:request]) @status = Element::Status.parse(info[:status]) @referer = Element::Referer.parse(info[:referer]) @user_agent = Element::UserAgent.parse(info[:user_agent]) end |
Instance Attribute Details
#referer ⇒ Object
Returns the value of attribute referer.
9 10 11 |
# File 'lib/http-log-analyzer/entry.rb', line 9 def referer @referer end |
#request ⇒ Object
Returns the value of attribute request.
7 8 9 |
# File 'lib/http-log-analyzer/entry.rb', line 7 def request @request end |
#source ⇒ Object
Returns the value of attribute source.
6 7 8 |
# File 'lib/http-log-analyzer/entry.rb', line 6 def source @source end |
#status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/http-log-analyzer/entry.rb', line 8 def status @status end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
5 6 7 |
# File 'lib/http-log-analyzer/entry.rb', line 5 def @timestamp end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
10 11 12 |
# File 'lib/http-log-analyzer/entry.rb', line 10 def user_agent @user_agent end |
Instance Method Details
#calendar_week ⇒ Object
22 23 24 |
# File 'lib/http-log-analyzer/entry.rb', line 22 def calendar_week '%s - %s' % [1, 7].map { |d| DateTime.commercial(@timestamp.year, @timestamp.cweek, d).to_date } end |