Class: Groonga::Posting

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga/posting.rb

Overview

This class keeps posting information.

Since:

  • 1.2.1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters = nil) ⇒ Object

Creates a new Posting.

Since:

  • 1.2.1



55
56
57
# File 'lib/groonga/posting.rb', line 55

def initialize(parameters=nil)
  update(parameters || {})
end

Instance Attribute Details

#lexiconGroonga::Table (readonly)

Returns The table of the term ID.

Returns:

Since:

  • 1.2.1



50
51
52
# File 'lib/groonga/posting.rb', line 50

def lexicon
  @lexicon
end

#n_rest_postingsObject

The number of rest posting information for the term ID.

Since:

  • 1.2.1



44
45
46
# File 'lib/groonga/posting.rb', line 44

def n_rest_postings
  @n_rest_postings
end

#positionObject

The position.

Since:

  • 1.2.1



35
36
37
# File 'lib/groonga/posting.rb', line 35

def position
  @position
end

#record_idObject

The record ID.

Since:

  • 1.2.1



26
27
28
# File 'lib/groonga/posting.rb', line 26

def record_id
  @record_id
end

#section_idObject

The section ID.

Since:

  • 1.2.1



29
30
31
# File 'lib/groonga/posting.rb', line 29

def section_id
  @section_id
end

#tableGroonga::Table (readonly)

Returns The table of the record ID.

Returns:

Since:

  • 1.2.1



47
48
49
# File 'lib/groonga/posting.rb', line 47

def table
  @table
end

#term_frequencyObject

The term frequency.

Since:

  • 1.2.1



38
39
40
# File 'lib/groonga/posting.rb', line 38

def term_frequency
  @term_frequency
end

#term_idObject

The term ID.

Since:

  • 1.2.1



32
33
34
# File 'lib/groonga/posting.rb', line 32

def term_id
  @term_id
end

#weightObject

The weight.

Since:

  • 1.2.1



41
42
43
# File 'lib/groonga/posting.rb', line 41

def weight
  @weight
end

Instance Method Details

#recordGroonga::Record?

Returns The record for the record ID. If table isn’t assosiated, nil is returned.

Returns:

  • (Groonga::Record, nil)

    The record for the record ID. If table isn’t assosiated, nil is returned.

Since:

  • 2.0.6



101
102
103
104
# File 'lib/groonga/posting.rb', line 101

def record
  return nil unless @table
  Record.new(@table, @record_id)
end

#termGroonga::Record?

Returns The record for the term ID. If lexicon isn’t assosiated, nil is returned.

Returns:

  • (Groonga::Record, nil)

    The record for the term ID. If lexicon isn’t assosiated, nil is returned.

Since:

  • 2.0.6



110
111
112
113
# File 'lib/groonga/posting.rb', line 110

def term
  return nil unless @lexicon
  Record.new(@lexicon, @term_id)
end

#to_hashObject

Returns Hash created from attributes.

Since:

  • 1.2.1



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/groonga/posting.rb', line 85

def to_hash
  {
    :record_id => @record_id,
    :section_id => @section_id,
    :term_id => @term_id,
    :position => @position,
    :term_frequency => @term_frequency,
    :weight => @weight,
    :n_rest_postings => @n_rest_postings
  }
end

#update(parameters) ⇒ Object

Updates all values.

Parameters:

  • parameters (::Hash)

    オプションを設定するハッシュ。指定されなかったオプションはデフォルト値が使われます。

Options Hash (parameters):

  • :record_id (Integer)

    The record_id.

  • :section_id (Integer)

    The section_id.

  • :term_id (Integer)

    The term_id.

  • :position (Integer)

    The position.

  • :term_frequency (Integer)

    The term_frequency.

  • :weight (Integer)

    The weight.

  • :n_rest_postings (Integer)

    The n_rest_postings.

  • :table (Groonga::Table)

    The table of the record ID.

  • :lexicon (Groonga::Table)

    The table of the term ID.

Since:

  • 1.2.1



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/groonga/posting.rb', line 72

def update(parameters)
  @record_id = parameters[:record_id] || nil
  @section_id = parameters[:section_id] || nil
  @term_id = parameters[:term_id] || nil
  @position = parameters[:position] || 0
  @term_frequency = parameters[:term_frequency] || 0
  @weight = parameters[:weight] || 0
  @n_rest_postings = parameters[:n_rest_postings] || 0
  @table = parameters[:table]
  @lexicon = parameters[:lexicon]
end