Module: RgvizRails
- Defined in:
- lib/rgviz_rails.rb,
lib/rgviz_rails/parser.rb
Defined Under Namespace
Classes: Parser
Class Method Summary collapse
- .date(date) ⇒ Object
- .datetime(time) ⇒ Object
- .inherits_from_active_record(obj) ⇒ Object
- .time_of_day(time) ⇒ Object
Class Method Details
.date(date) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rgviz_rails.rb', line 8 def self.date(date) def date.as_json( = {}) self end def date.encode_json(*) month = strftime("%m").to_i - 1 "new Date(#{strftime("%Y,#{month},%d")})" end date end |
.datetime(time) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rgviz_rails.rb', line 19 def self.datetime(time) def time.as_json(*) self end def time.encode_json(*) month = strftime("%m").to_i - 1 "new Date(#{strftime("%Y,#{month},%d,%H,%M,%S")})" end time end |
.inherits_from_active_record(obj) ⇒ Object
40 41 42 |
# File 'lib/rgviz_rails.rb', line 40 def self.inherits_from_active_record(obj) (obj.is_a?(Class) && obj < ActiveRecord::Base) || obj.is_a?(ActiveRecord::Relation) end |
.time_of_day(time) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/rgviz_rails.rb', line 30 def self.time_of_day(time) def time.as_json(*) self end def time.encode_json(*) "new Date(#{strftime('0,0,0,%H,%M,%S')})" end time end |