Class: Riddle::Configuration::Index

Inherits:
Section
  • Object
show all
Includes:
IndexSettings
Defined in:
lib/riddle/configuration/index.rb

Instance Attribute Summary collapse

Attributes included from IndexSettings

#bigram_freq_words, #bigram_index, #blend_chars, #blend_mode, #charset_dictpath, #charset_table, #charset_type, #dict, #docinfo, #enable_star, #exception_files, #expand_keywords, #global_idf, #ha_strategy, #hitless_words, #html_index_attrs, #html_remove_element_tags, #html_strip, #ignore_characters, #index_exact_words, #index_field_lengths, #index_sp, #index_zones, #infix_field_names, #inplace_docinfo_gap, #inplace_enable, #inplace_hit_gap, #inplace_reloc_factor, #inplace_write_factor, #min_infix_len, #min_prefix_len, #min_stemming_len, #min_word_len, #mlock, #morphologies, #name, #ngram_characters, #ngram_len, #ondisk_attrs, #ondisk_dict, #overshort_step, #path, #phrase_boundaries, #phrase_boundary_step, #prefix_field_names, #preopen, #regexp_filter, #rlp_context, #stopword_files, #stopwords_step, #stopwords_unstemmed, #type, #wordform_files

Class Method Summary collapse

Instance Method Summary collapse

Methods included from IndexSettings

#exceptions, #exceptions=, #html_remove_elements, #html_remove_elements=, #ignore_chars, #ignore_chars=, #infix_fields, #infix_fields=, #initialize_settings, #morphology, #morphology=, #ngram_chars, #ngram_chars=, #phrase_boundary, #phrase_boundary=, #prefix_fields, #prefix_fields=, #stopwords, #stopwords=, #wordforms, #wordforms=

Constructor Details

#initialize(name, *sources) ⇒ Index

Returns a new instance of Index.



14
15
16
17
18
19
# File 'lib/riddle/configuration/index.rb', line 14

def initialize(name, *sources)
  @name                     = name
  @sources                  = sources

  initialize_settings
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



12
13
14
# File 'lib/riddle/configuration/index.rb', line 12

def parent
  @parent
end

#sourcesObject

Returns the value of attribute sources.



12
13
14
# File 'lib/riddle/configuration/index.rb', line 12

def sources
  @sources
end

Class Method Details

.settingsObject



8
9
10
# File 'lib/riddle/configuration/index.rb', line 8

def self.settings
  Riddle::Configuration::IndexSettings.settings + [:source]
end

Instance Method Details

#renderObject

Raises:



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/riddle/configuration/index.rb', line 25

def render
  raise ConfigurationError, "#{@name} #{@sources.inspect} #{@path} #{@parent}" unless valid?

  inherited_name = parent ? "#{name} : #{parent}" : "#{name}"
  (
    @sources.collect { |s| s.render } +
    ["index #{inherited_name}", "{"] +
    settings_body +
    ["}", ""]
  ).join("\n")
end

#sourceObject



21
22
23
# File 'lib/riddle/configuration/index.rb', line 21

def source
  @sources.collect { |s| s.name }
end

#valid?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/riddle/configuration/index.rb', line 37

def valid?
  (!@name.nil?) && (!( @sources.length == 0 || @path.nil? ) || !@parent.nil?)
end