Class: Qiita::Elasticsearch::DateToken::BaseDateExpression

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

Constant Summary collapse

FIELD_NAMES_TABLE =
{
  "created" => "created_at",
  "updated" => "updated_at",
}

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ BaseDateExpression

Returns a new instance of BaseDateExpression.

Parameters:

  • token (DateToken)

    date token instance containing date expressions



20
21
22
# File 'lib/qiita/elasticsearch/date_token.rb', line 20

def initialize(token)
  @token = token
end

Instance Method Details

#converted_field_nameString

e.g. created:2000-01-01 -> created_at

Returns:

  • (String)


34
35
36
# File 'lib/qiita/elasticsearch/date_token.rb', line 34

def converted_field_name
  FIELD_NAMES_TABLE[@token.field_name] || @token.field_name
end

#matchObject



24
25
26
# File 'lib/qiita/elasticsearch/date_token.rb', line 24

def match
  @match ||= self.class::PATTERN.match(@token.range_query || @token.term)
end

#to_hashObject



28
29
30
# File 'lib/qiita/elasticsearch/date_token.rb', line 28

def to_hash
  fail NotImplementedError
end