Sha256: bacac8be39b5a53d5a0d0c8db420ee4f62db9e56f360f9db784cf5a8d1a47722

Contents?: true

Size: 892 Bytes

Versions: 15

Compression:

Stored size: 892 Bytes

Contents

module SplitIoClient
  #
  # helper class to parse fetched segments
  #
  class SegmentParser < NoMethodError
    #
    # segments data
    attr_accessor :segments

    #
    # since value for segments
    attr_accessor :since

    def initialize(logger)
      @segments = []
      @since = -1
      @logger = logger
    end

    #
    # method to get a segment by name
    #
    # @param name [string] segment name
    #
    # @return [object] segment object
    def get_segment(name)
      @segments.find { |s| s.name == name }
    end

    #
    # method to get all segment names within the structure
    #
    # @return [object] array of segment names
    def get_segment_names
      @segments.map { |seg| seg.name }
    end

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

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

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