Module: HSQL::Data
Overview
This module provides a set of useful values to be inserted into templates.
Instance Method Summary collapse
-
#for_humans ⇒ Object
For presenting to users the possible template variables they can use.
-
#for_machines(time) ⇒ Object
The internal API for reading this data and inserting it into queries.
Instance Method Details
#for_humans ⇒ Object
For presenting to users the possible template variables they can use.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hsql/data.rb', line 15 def for_humans values = calendar_moments(Time.current) for_screen = values.map do |name, _, description| ["{{{#{name}}}}", description] end width = for_screen.max_by { |name, _| name.size }.first.size for_screen.map do |name, documentation| " #{name.ljust(width, ' ')} #{documentation}" end.join("\n") end |
#for_machines(time) ⇒ Object
The internal API for reading this data and inserting it into queries.
8 9 10 11 12 |
# File 'lib/hsql/data.rb', line 8 def for_machines(time) Hash[ calendar_moments(time).map { |name, value, _documentation| [name, "'#{value}'"] } ] end |