Module: ScoutAgent::CoreExtensions::Time
- Defined in:
- lib/scout_agent/core_extensions.rb
Overview
Extensions for the Time class.
Instance Method Summary collapse
-
#to_db_s(trim_seconds = false) ⇒ Object
Returns a String version of this Time in the format expected by SQLite.
-
#to_json(*args) ⇒ Object
Half of the support for the round-tripping of Time objects to and from JSON.
Instance Method Details
#to_db_s(trim_seconds = false) ⇒ Object
Returns a String version of this Time in the format expected by SQLite. If trim_seconds
is true
, the sec() of this Time object will not be included in the String representation.
301 302 303 |
# File 'lib/scout_agent/core_extensions.rb', line 301 def to_db_s(trim_seconds = false) strftime("%Y-%m-%d %H:%M#{':%S' unless trim_seconds}") end |
#to_json(*args) ⇒ Object
Half of the support for the round-tripping of Time objects to and from JSON. This method builds a JSON object representation for Time objects compatible with the JSON library’s Ruby conversion support.
310 311 312 |
# File 'lib/scout_agent/core_extensions.rb', line 310 def to_json(*args) {:json_class => self.class.name, :data => to_a}.to_json(*args) end |