class Qiita::Elasticsearch::DateToken::RelativeDateExpression
Constants
- PATTERN
@note Matches to “30d” and “30days”
Public Instance Methods
to_hash()
click to toggle source
# File lib/qiita/elasticsearch/date_token.rb, line 108 def to_hash if @token.range_parameter { "range" => { converted_field_name => { @token.range_parameter => relative_range_with_hours, }, }, } else Nodes::NullNode.new.to_hash end end
Private Instance Methods
convert_to_hours()
click to toggle source
@return [Integer]
# File lib/qiita/elasticsearch/date_token.rb, line 130 def convert_to_hours case match[:type] when "d", "day", "days" match[:digit].to_i * 24 when "y", "year", "years" match[:digit].to_i * 24 * 365 else fail NotImplementedError end end
relative_range_with_hours()
click to toggle source
# File lib/qiita/elasticsearch/date_token.rb, line 124 def relative_range_with_hours @relative_range_with_hours ||= "now-" + convert_to_hours.to_s + "h" end