Class: Timetrap::Formatters::Json
- Inherits:
-
Object
- Object
- Timetrap::Formatters::Json
- Defined in:
- lib/timetrap/formatters/json.rb
Instance Attribute Summary collapse
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(entries) ⇒ Json
constructor
A new instance of Json.
Constructor Details
#initialize(entries) ⇒ Json
Returns a new instance of Json.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/timetrap/formatters/json.rb', line 16 def initialize entries @output = entries.map do |e| next unless e.end e.values.inject({}) do |h, (k,v)| h[k] = v h[k] = e.public_send(k) if %i[end start].include?(k) h end end.compact.to_json end |
Instance Attribute Details
#output ⇒ Object
Returns the value of attribute output.
14 15 16 |
# File 'lib/timetrap/formatters/json.rb', line 14 def output @output end |