Sha256: e3287245d7305aba5017c8db7f0e0910032a34944a79a29779f01e4869046a9c

Contents?: true

Size: 1.28 KB

Versions: 15

Compression:

Stored size: 1.28 KB

Contents

module SplitIoClient
  #
  # acts as dto for a split structure
  #
  class Split < NoMethodError
    #
    # definition of the split
    #
    # @returns [object] split values
    attr_accessor :data

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

    #
    # @returns [string] name of the split
    def name
      @data[:name]
    end

    #
    # @returns [int] seed value of the split
    def seed
      @data[:seed]
    end

    #
    # @returns [string] status value of the split
    def status
      @data[:status]
    end

    #
    # @returns [string] killed value of the split
    def killed?
      @data[:killed]
    end

    #
    # @returns [object] array of condition objects for this split
    def conditions
      @conditions
    end

    #
    # @return [boolean] true if the condition is empty false otherwise
    def is_empty?
      @data.empty? ? true : false
    end

    #
    # converts the conditions data into an array of condition objects for this split
    #
    # @return [object] array of condition objects
    def set_conditions
      conditions_list = []
      @data[:conditions].each do |c|
        condition = SplitIoClient::Condition.new(c)
        conditions_list << condition
      end
      conditions_list
    end

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
splitclient-rb-2.0.1 lib/splitclient-engine/parser/split.rb
splitclient-rb-2.0.0 lib/splitclient-engine/parser/split.rb
splitclient-rb-1.0.4 lib/splitclient-engine/parser/split.rb
splitclient-rb-1.0.4.wip3 lib/splitclient-engine/parser/split.rb
splitclient-rb-1.0.4.wip2 lib/splitclient-engine/parser/split.rb
splitclient-rb-1.0.4.wip lib/splitclient-engine/parser/split.rb
splitclient-rb-1.0.3 lib/splitclient-engine/parser/split.rb
splitclient-rb-1.0.3.wip2 lib/splitclient-engine/parser/split.rb
splitclient-rb-1.0.3.wip1 lib/splitclient-engine/parser/split.rb
splitclient-rb-1.0.2 lib/splitclient-engine/parser/split.rb
splitclient-rb-1.0.2.wip2 lib/splitclient-engine/parser/split.rb
splitclient-rb-1.0.2.wip lib/splitclient-engine/parser/split.rb
splitclient-rb-1.0.1 lib/splitclient-engine/parser/split.rb
splitclient-rb-1.0.0 lib/splitclient-engine/parser/split.rb
splitclient-rb-0.1.3 lib/splitclient-engine/parser/split.rb