Sha256: c2629f4ae5c7741e585bf4f80224b07e6ffa851650f38ad67d415dbdb7b5cef4

Contents?: true

Size: 1.15 KB

Versions: 25

Compression:

Stored size: 1.15 KB

Contents

module Exlibris
  module Primo
    require 'iso-639'
    #
    # Primo facet value that holds the name of the value
    # and the number of records that limiting by this facet
    # value would return.
    #
    class FacetValue
      include Config::Attributes
      include WriteAttributes
      include XmlUtil

      attr_accessor :facet

      def initialize *args
        @raw_xml = args.last.delete(:raw_xml)
        super
      end

      def name
        @name ||= xml.root["KEY"]
      end

      def display_name
        return @display_name ||= (ISO_639.find(name).english_name || name) if facet.name.eql? "lang"
        return @display_name ||= (config.libraries[name] || name) if facet.name.eql? "library"
        return @display_name ||= (config.facet_top_level[name] || name) if facet.name.eql? "tlevel"
        return @display_name ||= (config.facet_collections[name] || name) if facet.name.eql? "domain"
        return @display_name ||= (config.facet_resource_types[name] || name) if facet.name.eql? "rtype"
        @display_name ||= name
      end

      def size
        @size = Integer(xml.root["VALUE"])
      end
      alias :count :size
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
exlibris-primo-2.1.1 lib/exlibris/primo/facet_value.rb
exlibris-primo-2.1.0 lib/exlibris/primo/facet_value.rb
exlibris-primo-2.0.0 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.1.9 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.1.8 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.1.7 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.1.6 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.1.5 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.1.4 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.1.3 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.1.2 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.1.1 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.1.0 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.0.11 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.0.10 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.0.9 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.0.8 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.0.7 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.0.6 lib/exlibris/primo/facet_value.rb
exlibris-primo-1.0.5 lib/exlibris/primo/facet_value.rb