Exception: SplitIoClient::Split

Inherits:
NoMethodError
  • Object
show all
Defined in:
lib/engine/parser/split.rb

Overview

acts as dto for a split structure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(split) ⇒ Split

Returns a new instance of Split.



12
13
14
15
# File 'lib/engine/parser/split.rb', line 12

def initialize(split)
  @data = split
  @conditions = set_conditions
end

Instance Attribute Details

#dataObject

definition of the split



10
11
12
# File 'lib/engine/parser/split.rb', line 10

def data
  @data
end

Instance Method Details

#conditionsObject



43
44
45
# File 'lib/engine/parser/split.rb', line 43

def conditions
  @conditions
end

#empty?boolean

Returns true if the condition is empty false otherwise.

Returns:

  • (boolean)

    true if the condition is empty false otherwise



49
50
51
# File 'lib/engine/parser/split.rb', line 49

def empty?
  @data.empty?
end

#killed?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/engine/parser/split.rb', line 37

def killed?
  @data[:killed]
end

#nameObject



19
20
21
# File 'lib/engine/parser/split.rb', line 19

def name
  @data[:name]
end

#seedObject



25
26
27
# File 'lib/engine/parser/split.rb', line 25

def seed
  @data[:seed]
end

#set_conditionsobject

converts the conditions data into an array of condition objects for this split

Returns:

  • (object)

    array of condition objects



57
58
59
60
61
62
63
64
# File 'lib/engine/parser/split.rb', line 57

def set_conditions
  conditions_list = []
  @data[:conditions].each do |c|
    condition = SplitIoClient::Condition.new(c)
    conditions_list << condition
  end
  conditions_list
end

#statusObject



31
32
33
# File 'lib/engine/parser/split.rb', line 31

def status
  @data[:status]
end

#to_hObject



66
67
68
69
70
71
72
73
74
# File 'lib/engine/parser/split.rb', line 66

def to_h
  {
    name: name,
    seed: seed,
    status: status,
    killed: killed?,
    conditions: conditions
  }
end