Class: Experiment
- Inherits:
-
Object
- Object
- Experiment
- Defined in:
- lib/json/experiment.rb
Instance Attribute Summary collapse
-
#applications ⇒ Object
Returns the value of attribute applications.
-
#audience ⇒ Object
Returns the value of attribute audience.
-
#audience_strict ⇒ Object
Returns the value of attribute audience_strict.
-
#custom_field_values ⇒ Object
Returns the value of attribute custom_field_values.
-
#full_on_variant ⇒ Object
Returns the value of attribute full_on_variant.
-
#id ⇒ Object
Returns the value of attribute id.
-
#iteration ⇒ Object
Returns the value of attribute iteration.
-
#name ⇒ Object
Returns the value of attribute name.
-
#seed_hi ⇒ Object
Returns the value of attribute seed_hi.
-
#seed_lo ⇒ Object
Returns the value of attribute seed_lo.
-
#split ⇒ Object
Returns the value of attribute split.
-
#traffic_seed_hi ⇒ Object
Returns the value of attribute traffic_seed_hi.
-
#traffic_seed_lo ⇒ Object
Returns the value of attribute traffic_seed_lo.
-
#traffic_split ⇒ Object
Returns the value of attribute traffic_split.
-
#unit_type ⇒ Object
Returns the value of attribute unit_type.
-
#variants ⇒ Object
Returns the value of attribute variants.
Instance Method Summary collapse
- #==(o) ⇒ Object
- #assign_to_klass(klass, arr) ⇒ Object
- #hash_code ⇒ Object
-
#initialize(args = {}) ⇒ Experiment
constructor
A new instance of Experiment.
- #to_s ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Experiment
Returns a new instance of Experiment.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/json/experiment.rb', line 13 def initialize(args = {}) args.each do |name, value| if name == :applications @applications = assign_to_klass(ExperimentApplication, value) elsif name == :variants @variants = assign_to_klass(ExperimentVariant, value) elsif name == :customFieldValues if value != nil @custom_field_values = assign_to_klass(CustomFieldValue, value) end else self.instance_variable_set("@#{name.to_s.underscore}", value) end end @audience_strict ||= false self end |
Instance Attribute Details
#applications ⇒ Object
Returns the value of attribute applications.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def applications @applications end |
#audience ⇒ Object
Returns the value of attribute audience.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def audience @audience end |
#audience_strict ⇒ Object
Returns the value of attribute audience_strict.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def audience_strict @audience_strict end |
#custom_field_values ⇒ Object
Returns the value of attribute custom_field_values.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def custom_field_values @custom_field_values end |
#full_on_variant ⇒ Object
Returns the value of attribute full_on_variant.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def full_on_variant @full_on_variant end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def id @id end |
#iteration ⇒ Object
Returns the value of attribute iteration.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def iteration @iteration end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def name @name end |
#seed_hi ⇒ Object
Returns the value of attribute seed_hi.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def seed_hi @seed_hi end |
#seed_lo ⇒ Object
Returns the value of attribute seed_lo.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def seed_lo @seed_lo end |
#split ⇒ Object
Returns the value of attribute split.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def split @split end |
#traffic_seed_hi ⇒ Object
Returns the value of attribute traffic_seed_hi.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def traffic_seed_hi @traffic_seed_hi end |
#traffic_seed_lo ⇒ Object
Returns the value of attribute traffic_seed_lo.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def traffic_seed_lo @traffic_seed_lo end |
#traffic_split ⇒ Object
Returns the value of attribute traffic_split.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def traffic_split @traffic_split end |
#unit_type ⇒ Object
Returns the value of attribute unit_type.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def unit_type @unit_type end |
#variants ⇒ Object
Returns the value of attribute variants.
9 10 11 |
# File 'lib/json/experiment.rb', line 9 def variants @variants end |
Instance Method Details
#==(o) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/json/experiment.rb', line 39 def ==(o) return true if self.object_id == o.object_id return false if o.nil? || self.class != o.class that = o @id == that.id && @iteration == that.iteration && @seed_hi == that.seed_hi && @seed_lo == that.seed_lo && @traffic_seed_hi == that.traffic_seed_hi && @traffic_seed_lo == that.traffic_seed_lo && @full_on_variant == that.full_on_variant && @name == that.name && @unit_type == that.unit_type && @split == that.split && @traffic_split == that.traffic_split && @applications == that.applications && @variants == that.variants && @audience_strict == that.audience_strict && @audience == that.audience && @custom_field_values == that.custom_field_values end |
#assign_to_klass(klass, arr) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/json/experiment.rb', line 31 def assign_to_klass(klass, arr) arr.map do |item| return item if item.is_a?(klass) klass.new(*item.values) end end |
#hash_code ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/json/experiment.rb', line 53 def hash_code { id: @id, name: @name, unit_type: @unit_type, iteration: @iteration, seed_hi: @seed_hi, seed_lo: @seed_lo, traffic_seed_hi: @traffic_seed_hi, traffic_seed_lo: @traffic_seed_lo, full_on_variant: @full_on_variant, audience_strict: @audience_strict, audience: @audience, custom_field_values: @custom_field_values } end |
#to_s ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/json/experiment.rb', line 70 def to_s "ContextExperiment{" + "id= #{@id}"+ ", name='#{@name}'" + ", unitType='#{@unit_type}'" + ", iteration=#{@iteration}" + ", seedHi=#{@seed_hi}" + ", seedLo=#{@seed_lo}" + ", split=#{@split.join}" + ", trafficSeedHi=#{@traffic_seed_hi}" + ", trafficSeedLo=#{@traffic_seed_lo}" + ", trafficSplit=#{@traffic_split.join}" + ", fullOnVariant=#{@full_on_variant}" + ", applications=#{@applications.join}" + ", variants=#{@variants.join}" + ", audienceStrict=#{@audience_strict}" + ", audience='#{@audience}'" + ", custom_field_values='#{@custom_field_values}'" + "}" end |