Class: WorkLogResponse
- Inherits:
-
Object
- Object
- WorkLogResponse
- Defined in:
- lib/webserver.rb
Overview
Class to render the main page of the WorkLog web application.
Instance Method Summary collapse
-
#initialize(storage, tags) ⇒ WorkLogResponse
constructor
A new instance of WorkLogResponse.
- #response(request) ⇒ Object
Constructor Details
#initialize(storage, tags) ⇒ WorkLogResponse
Returns a new instance of WorkLogResponse.
29 30 31 32 |
# File 'lib/webserver.rb', line 29 def initialize(storage, ) @storage = storage @tags = end |
Instance Method Details
#response(request) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/webserver.rb', line 34 def response(request) template = ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', 'index.html.erb')), trim_mode: '-') @params = request.params days = @params['days'].nil? ? 7 : @params['days'].to_i = @params['tags'].nil? ? nil : @params['tags'].split(',') epics_only = @params['epics_only'] == 'true' presentation = @params['presentation'] == 'true' logs = @storage.days_between(Date.today - days, Date.today, epics_only, ).reverse [200, {}, [template.result_with_hash( { days:, tags: , epics_only:, presentation:, logs:, update_query: method(:update_query), build_uri: method(:build_uri) } )]] end |