class Elastic::Nodes::Agg::DateHistogram
Attributes
field[RW]
interval[R]
time_zone[R]
Public Class Methods
build(_name, _field, interval: nil, time_zone: nil)
click to toggle source
Calls superclass method
Elastic::Nodes::BaseAgg::build
# File lib/elastic/nodes/agg/date_histogram.rb, line 6 def self.build(_name, _field, interval: nil, time_zone: nil) super(_name).tap do |node| node.field = _field node.interval = interval node.time_zone = time_zone end end
Public Instance Methods
clone()
click to toggle source
Calls superclass method
Elastic::Nodes::Concerns::Aggregable#clone
# File lib/elastic/nodes/agg/date_histogram.rb, line 27 def clone prepare_clone(super) end
interval=(_value)
click to toggle source
# File lib/elastic/nodes/agg/date_histogram.rb, line 17 def interval=(_value) raise ArgumentError, 'invalid interval' if _value && !valid_interval?(_value) @interval = _value end
render(_options = {})
click to toggle source
# File lib/elastic/nodes/agg/date_histogram.rb, line 35 def render(_options = {}) hash = { 'field' => @field.to_s } hash['interval'] = @interval if @interval hash['time_zone'] = @time_zone.formatted_offset if @time_zone render_aggs({ 'date_histogram' => hash }, _options) end
simplify()
click to toggle source
Calls superclass method
Elastic::Nodes::Concerns::Aggregable#simplify
# File lib/elastic/nodes/agg/date_histogram.rb, line 31 def simplify prepare_clone(super) end
time_zone=(_value)
click to toggle source
# File lib/elastic/nodes/agg/date_histogram.rb, line 22 def time_zone=(_value) raise ArgumentError, 'invalid time_zone' if _value && !_value.is_a?(ActiveSupport::TimeZone) @time_zone = _value end
Private Instance Methods
prepare_clone(_clone)
click to toggle source
# File lib/elastic/nodes/agg/date_histogram.rb, line 45 def prepare_clone(_clone) _clone.field = @field _clone.interval = @interval _clone.time_zone = @time_zone _clone end
valid_interval?(_value)
click to toggle source
# File lib/elastic/nodes/agg/date_histogram.rb, line 52 def valid_interval?(_value) /^\d+(\.\d+)?(y|M|w|d|h|m|s)$/ === _value end