Class: PlanOut::Assignment
- Inherits:
-
Object
- Object
- PlanOut::Assignment
- Defined in:
- lib/plan_out/assignment.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#experiment_salt ⇒ Object
Returns the value of attribute experiment_salt.
Instance Method Summary collapse
- #[](x) ⇒ Object
- #[]=(x, y) ⇒ Object
- #evaluate(data) ⇒ Object
- #get(var, default = nil) ⇒ Object
- #get_params ⇒ Object
-
#initialize(experiment_salt) ⇒ Assignment
constructor
A new instance of Assignment.
-
#set(name, value) ⇒ Object
in python this would be defined as __setattr__ or __setitem__ not sure how to do this in Ruby.
Constructor Details
#initialize(experiment_salt) ⇒ Assignment
5 6 7 8 |
# File 'lib/plan_out/assignment.rb', line 5 def initialize(experiment_salt) @experiment_salt = experiment_salt @data = {} end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/plan_out/assignment.rb', line 3 def data @data end |
#experiment_salt ⇒ Object
Returns the value of attribute experiment_salt.
3 4 5 |
# File 'lib/plan_out/assignment.rb', line 3 def experiment_salt @experiment_salt end |
Instance Method Details
#[](x) ⇒ Object
29 30 31 |
# File 'lib/plan_out/assignment.rb', line 29 def [](x) get(x) end |
#[]=(x, y) ⇒ Object
33 34 35 |
# File 'lib/plan_out/assignment.rb', line 33 def []=(x,y) set(x,y) end |
#evaluate(data) ⇒ Object
10 11 12 |
# File 'lib/plan_out/assignment.rb', line 10 def evaluate(data) data end |
#get(var, default = nil) ⇒ Object
14 15 16 |
# File 'lib/plan_out/assignment.rb', line 14 def get(var, default = nil) @data[var.to_sym] || default end |
#get_params ⇒ Object
37 38 39 |
# File 'lib/plan_out/assignment.rb', line 37 def get_params @data end |
#set(name, value) ⇒ Object
in python this would be defined as __setattr__ or __setitem__ not sure how to do this in Ruby.
20 21 22 23 24 25 26 27 |
# File 'lib/plan_out/assignment.rb', line 20 def set(name, value) if value.is_a? Operator value.args[:salt] = name if !value.args.has_key?(:salt) @data[name.to_sym] = value.execute(self) else @data[name.to_sym] = value end end |