Module: LazyHighCharts::OptionsKeyFilter
- Defined in:
- lib/lazy_high_charts/options_key_filter.rb
Constant Summary collapse
- FILTER_MAP =
{ method(:milliseconds) => [:pointInterval], method(:date_to_js_code) => [:pointStart] }
Class Method Summary collapse
Class Method Details
.date_to_js_code(date) ⇒ Object
16 17 18 |
# File 'lib/lazy_high_charts/options_key_filter.rb', line 16 def self.date_to_js_code date "Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})".js_code end |
.filter(options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lazy_high_charts/options_key_filter.rb', line 20 def self.filter = .map do |k, v| if v.is_a? ::Hash v = filter v else FILTER_MAP.each_pair do |method, matchers| v = method.call(v) if matchers.include?(k) end end [k, v] end Hash[] end |
.milliseconds(value) ⇒ Object
12 13 14 |
# File 'lib/lazy_high_charts/options_key_filter.rb', line 12 def self.milliseconds value value * 1000 end |