Class: Annotations2triannon::Configuration
- Inherits:
-
Object
- Object
- Annotations2triannon::Configuration
- Defined in:
- lib/annotations2triannon/configuration.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#limit_annolists ⇒ Object
Returns the value of attribute limit_annolists.
-
#limit_manifests ⇒ Object
Returns the value of attribute limit_manifests.
-
#limit_openannos ⇒ Object
Returns the value of attribute limit_openannos.
-
#limit_random ⇒ Object
Returns the value of attribute limit_random.
-
#log_file ⇒ Object
readonly
Returns the value of attribute log_file.
-
#log_path ⇒ Object
readonly
Returns the value of attribute log_path.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
-
#array_sampler(array, limit = 0) ⇒ Object
Utility method for sampling annotation arrays, using either linear or random sampling of a subset of elements.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/annotations2triannon/configuration.rb', line 18 def initialize @debug = env_boolean('DEBUG') logger_init # In development, enable options for sampling the data @limit_random = env_boolean('ANNO_LIMIT_RANDOM') # 0..limit or random sampling @limit_manifests = ENV['ANNO_LIMIT_MANIFESTS'].to_i # 0 disables sampling @limit_annolists = ENV['ANNO_LIMIT_ANNOLISTS'].to_i # 0 disables sampling @limit_openannos = ENV['ANNO_LIMIT_OPENANNOS'].to_i # 0 disables sampling # Persistence options (TODO: provide options for triple stores) redis_init end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
10 11 12 |
# File 'lib/annotations2triannon/configuration.rb', line 10 def debug @debug end |
#limit_annolists ⇒ Object
Returns the value of attribute limit_annolists.
13 14 15 |
# File 'lib/annotations2triannon/configuration.rb', line 13 def limit_annolists @limit_annolists end |
#limit_manifests ⇒ Object
Returns the value of attribute limit_manifests.
12 13 14 |
# File 'lib/annotations2triannon/configuration.rb', line 12 def limit_manifests @limit_manifests end |
#limit_openannos ⇒ Object
Returns the value of attribute limit_openannos.
14 15 16 |
# File 'lib/annotations2triannon/configuration.rb', line 14 def limit_openannos @limit_openannos end |
#limit_random ⇒ Object
Returns the value of attribute limit_random.
11 12 13 |
# File 'lib/annotations2triannon/configuration.rb', line 11 def limit_random @limit_random end |
#log_file ⇒ Object (readonly)
Returns the value of attribute log_file.
6 7 8 |
# File 'lib/annotations2triannon/configuration.rb', line 6 def log_file @log_file end |
#log_path ⇒ Object (readonly)
Returns the value of attribute log_path.
7 8 9 |
# File 'lib/annotations2triannon/configuration.rb', line 7 def log_path @log_path end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/annotations2triannon/configuration.rb', line 8 def logger @logger end |
#redis ⇒ Object
Returns the value of attribute redis.
16 17 18 |
# File 'lib/annotations2triannon/configuration.rb', line 16 def redis @redis end |
Instance Method Details
#array_sampler(array, limit = 0) ⇒ Object
Utility method for sampling annotation arrays, using either linear or random sampling of a subset of elements. The instance variable .limit_random is a configuration parameter that defines whether linear or random sampling is used.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/annotations2triannon/configuration.rb', line 39 def array_sampler(array, limit=0) if limit > 0 if @limit_random array.sample(limit) else limit = limit - 1 array[0..limit] end else array end end |