Sha256: ade93afe8a4316c30fcd1c222d7709682232f190d7556bfd68fa1492886f60ce

Contents?: true

Size: 866 Bytes

Versions: 7

Compression:

Stored size: 866 Bytes

Contents

module Endeca
  class Refinement
    include Readers

    reader 'DimensionName' => :name,
      'ExpansionLink' => :expansion_link,
      'ContractionLink' => :contraction_link

    integer_reader 'DimensionID' => :id

    reader('DimensionValues' => :dimension_values) do |values|
      values.map{|value| Dimension.new(value)} if values
    end

    reader('Dimensions' => :dimensions) do |values|
      values.map{|value| RefinementDimension.new(value)} if values
    end

    attr_reader :raw
    def initialize(raw={})
      @raw = raw
    end

    def ==(other)
      id == other.id
    end

    def inspect
      "#<#{self.class}=0x#{self.object_id.to_s(16)} id=#{id} name=#{name.inspect}>"
    end

    def attributes
      (@raw['Dimensions'] || []).first || {}
    end

    def to_endeca_params
      expansion_link || contraction_link
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
endeca-1.5.3 lib/endeca/refinement.rb
endeca-1.5.2 lib/endeca/refinement.rb
endeca-1.5.1 lib/endeca/refinement.rb
endeca-1.5.0 lib/endeca/refinement.rb
endeca-1.4.2 lib/endeca/refinement.rb
endeca-1.4.1 lib/endeca/refinement.rb
endeca-1.4.0 lib/endeca/refinement.rb