Class: Groonga::Posting
- Inherits:
-
Object
- Object
- Groonga::Posting
- Defined in:
- lib/groonga/posting.rb
Overview
This class keeps posting information.
Instance Attribute Summary collapse
-
#lexicon ⇒ Groonga::Table
readonly
The table of the term ID.
-
#n_rest_postings ⇒ Object
The number of rest posting information for the term ID.
-
#position ⇒ Object
The position.
-
#record_id ⇒ Object
The record ID.
-
#section_id ⇒ Object
The section ID.
-
#table ⇒ Groonga::Table
readonly
The table of the record ID.
-
#term_frequency ⇒ Object
The term frequency.
-
#term_id ⇒ Object
The term ID.
-
#weight ⇒ Object
The weight.
Instance Method Summary collapse
-
#initialize(parameters = nil) ⇒ Object
constructor
Creates a new Posting.
-
#record ⇒ Groonga::Record?
The record for the record ID.
-
#term ⇒ Groonga::Record?
The record for the term ID.
-
#to_hash ⇒ Object
Returns Hash created from attributes.
-
#update(parameters) ⇒ Object
Updates all values.
Constructor Details
#initialize(parameters = nil) ⇒ Object
Creates a new Posting.
55 56 57 |
# File 'lib/groonga/posting.rb', line 55 def initialize(parameters=nil) update(parameters || {}) end |
Instance Attribute Details
#lexicon ⇒ Groonga::Table (readonly)
Returns The table of the term ID.
50 51 52 |
# File 'lib/groonga/posting.rb', line 50 def lexicon @lexicon end |
#n_rest_postings ⇒ Object
The number of rest posting information for the term ID.
44 45 46 |
# File 'lib/groonga/posting.rb', line 44 def n_rest_postings @n_rest_postings end |
#position ⇒ Object
The position.
35 36 37 |
# File 'lib/groonga/posting.rb', line 35 def position @position end |
#record_id ⇒ Object
The record ID.
26 27 28 |
# File 'lib/groonga/posting.rb', line 26 def record_id @record_id end |
#section_id ⇒ Object
The section ID.
29 30 31 |
# File 'lib/groonga/posting.rb', line 29 def section_id @section_id end |
#table ⇒ Groonga::Table (readonly)
Returns The table of the record ID.
47 48 49 |
# File 'lib/groonga/posting.rb', line 47 def table @table end |
#term_frequency ⇒ Object
The term frequency.
38 39 40 |
# File 'lib/groonga/posting.rb', line 38 def term_frequency @term_frequency end |
#term_id ⇒ Object
The term ID.
32 33 34 |
# File 'lib/groonga/posting.rb', line 32 def term_id @term_id end |
#weight ⇒ Object
The weight.
41 42 43 |
# File 'lib/groonga/posting.rb', line 41 def weight @weight end |
Instance Method Details
#record ⇒ Groonga::Record?
Returns The record for the record ID. If table isn’t assosiated, nil is returned.
101 102 103 104 |
# File 'lib/groonga/posting.rb', line 101 def record return nil unless @table Record.new(@table, @record_id) end |
#term ⇒ Groonga::Record?
Returns The record for the term ID. If lexicon isn’t assosiated, nil is returned.
110 111 112 113 |
# File 'lib/groonga/posting.rb', line 110 def term return nil unless @lexicon Record.new(@lexicon, @term_id) end |
#to_hash ⇒ Object
Returns Hash created from attributes.
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.
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 |