Class: Settings
- Inherits:
-
Object
- Object
- Settings
- Defined in:
- lib/solrj_wrapper/settings.rb
Overview
Read the .yml file containing the configuration values
Instance Attribute Summary collapse
-
#log_file ⇒ Object
readonly
Returns the value of attribute log_file.
-
#log_level ⇒ Object
readonly
Returns the value of attribute log_level.
-
#solr_url ⇒ Object
readonly
Returns the value of attribute solr_url.
-
#solrj_jar_dir ⇒ Object
readonly
Returns the value of attribute solrj_jar_dir.
-
#solrj_num_threads ⇒ Object
readonly
Returns the value of attribute solrj_num_threads.
-
#solrj_queue_size ⇒ Object
readonly
Returns the value of attribute solrj_queue_size.
Instance Method Summary collapse
-
#as_hash ⇒ Object
The attributes of this class as a Hash.
- #get_log_level ⇒ Object
-
#initialize(settings_group) ⇒ Settings
constructor
A new instance of Settings.
Constructor Details
#initialize(settings_group) ⇒ Settings
Returns a new instance of Settings.
8 9 10 11 12 13 14 15 16 |
# File 'lib/solrj_wrapper/settings.rb', line 8 def initialize(settings_group) yml = YAML.load_file('lib/config/settings.yml')[settings_group] @solr_url = yml["solr_url"] @solrj_jar_dir = yml["solrj_jar_dir"] @solrj_queue_size = yml["solrj_queue_size"] @solrj_num_threads = yml["solrj_num_threads"] @log_level = yml["log_level"] @log_file = yml["log_file"] end |
Instance Attribute Details
#log_file ⇒ Object (readonly)
Returns the value of attribute log_file.
6 7 8 |
# File 'lib/solrj_wrapper/settings.rb', line 6 def log_file @log_file end |
#log_level ⇒ Object (readonly)
Returns the value of attribute log_level.
6 7 8 |
# File 'lib/solrj_wrapper/settings.rb', line 6 def log_level @log_level end |
#solr_url ⇒ Object (readonly)
Returns the value of attribute solr_url.
6 7 8 |
# File 'lib/solrj_wrapper/settings.rb', line 6 def solr_url @solr_url end |
#solrj_jar_dir ⇒ Object (readonly)
Returns the value of attribute solrj_jar_dir.
6 7 8 |
# File 'lib/solrj_wrapper/settings.rb', line 6 def solrj_jar_dir @solrj_jar_dir end |
#solrj_num_threads ⇒ Object (readonly)
Returns the value of attribute solrj_num_threads.
6 7 8 |
# File 'lib/solrj_wrapper/settings.rb', line 6 def solrj_num_threads @solrj_num_threads end |
#solrj_queue_size ⇒ Object (readonly)
Returns the value of attribute solrj_queue_size.
6 7 8 |
# File 'lib/solrj_wrapper/settings.rb', line 6 def solrj_queue_size @solrj_queue_size end |
Instance Method Details
#as_hash ⇒ Object
Returns the attributes of this class as a Hash.
19 20 21 22 23 24 25 26 27 |
# File 'lib/solrj_wrapper/settings.rb', line 19 def as_hash {:solr_url => @solr_url, :solrj_jar_dir => @solrj_jar_dir, :solrj_queue_size => @solrj_queue_size, :solrj_num_threads => @solrj_num_threads, :log_level => get_log_level, :log_file => @log_file } end |
#get_log_level ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/solrj_wrapper/settings.rb', line 29 def get_log_level case (@log_level) when "debug" logger_level = Logger::DEBUG when "warn" logger_level = Logger::WARN when "error" logger_level = Logger::ERROR when "fatal" logger_level = Logger::FATAL else logger_level = Logger::INFO end logger_level end |