Class: Qiita::Elasticsearch::DateToken::AbsoluteDateExpression

Inherits:
BaseDateExpression show all
Defined in:
lib/qiita/elasticsearch/date_token.rb

Constant Summary collapse

PATTERN =
Note:

Matches to “YYYY”, “YYYY-MM” and “YYYY-MM-DD”

/\A
  (?<year>\d{4})
  (?:
    -
    (?<month>\d{1,2})
    (?:
      -
      (?<day>\d{1,2})
    )?
  )?
\z/x

Constants inherited from BaseDateExpression

BaseDateExpression::FIELD_NAMES_TABLE

Instance Method Summary collapse

Methods inherited from BaseDateExpression

#converted_field_name, #initialize, #match

Constructor Details

This class inherits a constructor from Qiita::Elasticsearch::DateToken::BaseDateExpression

Instance Method Details

#to_hashObject



53
54
55
56
57
58
59
# File 'lib/qiita/elasticsearch/date_token.rb', line 53

def to_hash
  if @token.range_parameter
    range_block(@token.range_parameter => @token.range_query, "time_zone" => @token.time_zone)
  else
    range_block("gte" => beginning_of_range.to_s, "lt" => end_of_range.to_s, "time_zone" => @token.time_zone)
  end
end