Class: CollaborativeFilter::Config
- Inherits:
-
Object
- Object
- CollaborativeFilter::Config
- Defined in:
- lib/collaborative_filter/config.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#datasets ⇒ Object
readonly
Returns the value of attribute datasets.
-
#recommender_options ⇒ Object
readonly
Returns the value of attribute recommender_options.
Class Method Summary collapse
Instance Method Summary collapse
- #content_booster {|cb| ... } ⇒ Object
- #dataset(name) {|ds| ... } ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #recommender(input = nil, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
50 51 52 53 |
# File 'lib/collaborative_filter/config.rb', line 50 def initialize setup_defaults @datasets = {} end |
Instance Attribute Details
#datasets ⇒ Object (readonly)
Returns the value of attribute datasets.
26 27 28 |
# File 'lib/collaborative_filter/config.rb', line 26 def datasets @datasets end |
#recommender_options ⇒ Object (readonly)
Returns the value of attribute recommender_options.
26 27 28 |
# File 'lib/collaborative_filter/config.rb', line 26 def @recommender_options end |
Class Method Details
.config_option(option, default = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/collaborative_filter/config.rb', line 8 def self.config_option(option, default=nil) @@config_defaults ||= {} @@config_defaults[option] = default define_method(:setup_defaults) { @@config_defaults.each { |k,v| instance_variable_set("@#{k}".to_sym, v) } } unless instance_methods.include?('setup_defaults') class_eval <<-END def #{option}(input=nil) return @#{option} unless input @#{option} = input end END end |
Instance Method Details
#content_booster {|cb| ... } ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/collaborative_filter/config.rb', line 36 def content_booster return @content_booster unless block_given? cb = CollaborativeFilter::ContentBooster.new yield cb @content_booster = cb end |
#dataset(name) {|ds| ... } ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/collaborative_filter/config.rb', line 28 def dataset(name) raise Error.new('#dataset requires a block') unless block_given? ds = CollaborativeFilter::DataSet.new yield ds @datasets[name] = ds end |
#recommender(input = nil, options = {}) ⇒ Object
44 45 46 47 48 |
# File 'lib/collaborative_filter/config.rb', line 44 def recommender(input=nil, ={}) return @recommender unless input @recommender = input @recommender_options = end |