Class: Geckoboard::PayloadFormatter
- Inherits:
-
Object
- Object
- Geckoboard::PayloadFormatter
- Defined in:
- lib/geckoboard/payload_formatter.rb
Instance Attribute Summary collapse
-
#dataset ⇒ Object
readonly
Returns the value of attribute dataset.
Instance Method Summary collapse
- #format(payload) ⇒ Object
-
#initialize(dataset) ⇒ PayloadFormatter
constructor
A new instance of PayloadFormatter.
Constructor Details
#initialize(dataset) ⇒ PayloadFormatter
Returns a new instance of PayloadFormatter.
5 6 7 |
# File 'lib/geckoboard/payload_formatter.rb', line 5 def initialize(dataset) @dataset = dataset end |
Instance Attribute Details
#dataset ⇒ Object (readonly)
Returns the value of attribute dataset.
3 4 5 |
# File 'lib/geckoboard/payload_formatter.rb', line 3 def dataset @dataset end |
Instance Method Details
#format(payload) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/geckoboard/payload_formatter.rb', line 9 def format(payload) payload.map do |item| item.inject({}) do |hash, (field_name, value)| field_name = field_name.to_s value = case field_type(field_name) when 'date' then format_date(value) when 'datetime' then format_datetime(value) else value end hash.merge(field_name => value) end end end |