Class: Oculus::Presenters::QueryPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Oculus::Presenters::QueryPresenter
- Defined in:
- lib/oculus/presenters/query_presenter.rb
Instance Method Summary collapse
- #description ⇒ Object
- #elapsed_time ⇒ Object
- #formatted_finish_time ⇒ Object
- #formatted_start_time ⇒ Object
- #named? ⇒ Boolean
- #status ⇒ Object
Instance Method Details
#description ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/oculus/presenters/query_presenter.rb', line 48 def description if name && name != "" name else query = self.query if query && query.length > 100 "#{query[0..97]}..." else query end end end |
#elapsed_time ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/oculus/presenters/query_presenter.rb', line 14 def elapsed_time return "" unless started_at && finished_at seconds = (finished_at - started_at).round if seconds < 60 "#{seconds} seconds" else minutes = (seconds / 60).floor seconds %= 60 if minutes < 60 "#{minutes} minutes #{seconds} seconds" else hours = (minutes / 60).floor minutes %= 60 "#{hours} hours #{minutes} minutes" end end end |
#formatted_finish_time ⇒ Object
10 11 12 |
# File 'lib/oculus/presenters/query_presenter.rb', line 10 def formatted_finish_time finished_at.strftime("%Y-%m-%d %I:%M %p") if finished_at end |
#formatted_start_time ⇒ Object
6 7 8 |
# File 'lib/oculus/presenters/query_presenter.rb', line 6 def formatted_start_time started_at.strftime("%Y-%m-%d %I:%M %p") if started_at end |
#named? ⇒ Boolean
61 62 63 |
# File 'lib/oculus/presenters/query_presenter.rb', line 61 def named? !!name end |
#status ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/oculus/presenters/query_presenter.rb', line 36 def status if complete? if error "error" else "done" end else "loading" end end |