class Kameleoon::Targeting::Segment
Attributes
id[RW]
tree[RW]
Public Class Methods
new(*args)
click to toggle source
# 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
Public Instance Methods
check_tree(targeting_data)
click to toggle source
# 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()
click to toggle source
# File lib/kameleoon/targeting/models.rb, line 10 def to_s print("\nSegment id: " + @id.to_s) print("\n") @tree.to_s end