Module: HSQL::Data

Extended by:
Data
Included in:
Data
Defined in:
lib/hsql/data.rb

Overview

This module provides a set of useful values to be inserted into templates.

Instance Method Summary collapse

Instance Method Details

#for_humansObject

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