Class: Kameleoon::Targeting::Segment Private
- Inherits:
-
Object
- Object
- Kameleoon::Targeting::Segment
- Includes:
- TreeBuilder
- Defined in:
- lib/kameleoon/targeting/models.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #id ⇒ Object private
- #tree ⇒ Object private
Instance Method Summary collapse
- #check_tree(targeting_data) ⇒ Object private
-
#initialize(*args) ⇒ Segment
constructor
private
A new instance of Segment.
- #to_s ⇒ Object private
Methods included from TreeBuilder
Methods included from ConditionFactory
Constructor Details
#initialize(*args) ⇒ Segment
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Segment.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kameleoon/targeting/models.rb', line 16 def initialize(*args) unless args.empty? if args.length == 1 hash = args.first if hash.nil? raise Kameleoon::Exception::NotFound.new("arguments for segment") end if hash["id"].nil? raise Kameleoon::Exception::NotFound.new("id") end @id = hash["id"] if hash["conditionsData"].nil? raise Kameleoon::Exception::NotFound.new(hash["conditionsData"]) end @tree = create_tree(hash["conditionsData"]) elsif args.length == 2 @id = args[0] @tree = args[1] end end end |
Instance Attribute Details
#id ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/kameleoon/targeting/models.rb', line 9 def id @id end |
#tree ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/kameleoon/targeting/models.rb', line 9 def tree @tree end |
Instance Method Details
#check_tree(targeting_data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 43 44 45 |
# File 'lib/kameleoon/targeting/models.rb', line 38 def check_tree(targeting_data) if @tree.nil? is_targeted = true else is_targeted = @tree.check(targeting_data) end is_targeted == true end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 13 14 |
# File 'lib/kameleoon/targeting/models.rb', line 10 def to_s print("\nSegment id: " + @id.to_s) print("\n") @tree.to_s end |