Class: EDSApi::EDSAPIInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/edsapi_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info_raw) ⇒ EDSAPIInfo

Returns a new instance of EDSAPIInfo.



778
779
780
# File 'lib/edsapi_wrapper.rb', line 778

def initialize(info_raw)
	@info = info_raw
end

Instance Attribute Details

#infoObject

Returns the value of attribute info.



776
777
778
# File 'lib/edsapi_wrapper.rb', line 776

def info
  @info
end

Instance Method Details

#default_optionsObject



867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
# File 'lib/edsapi_wrapper.rb', line 867

def default_options
	options = {}
	self.search_modes.each do |search_mode|
		if search_mode['DefaultOn'] == "y"
			options['searchmode'] = [search_mode['Mode']]
		end
	end

	options['resultsperpage'] = [self.results_per_page]
	options['sort'] = ['relevance']
	options['view'] = [self.results_list_view]

	options['autosuggest'] = [self.did_you_mean[0]["DefaultOn"]]
	#pay attention to DID YOU MEAN default

	default_limiters = []
	self.limiters.each do |limiter|
		if limiter['Type'] == 'select' && limiter['DefaultOn'] == 'y'
			default_limiters.push(limiter['Id']+":"+'y')
		elsif limiter['Type'] == 'multiselectvalue'
			limiter['LimiterValues'].each do |limiter_value|
				unless limiter_value['DefaultOn'].nil?
					default_limiters.push(limiter['Id']+":"+limiter_value['Value'])
				end
			end
		end
	end
	if default_limiters.count > 0
		options['limiter'] = default_limiters
	end

	default_expanders = []
	self.expanders.each do |expander|
		if expander['DefaultOn'] == 'y'
			default_expanders.push(expander['Id'])
		end
	end
	if default_expanders.count > 0
		options['expander'] = default_expanders
	end

	default_relatedcontent = []
	self.related_content.each do |related_info|
		if related_info['DefaultOn'] == 'y'
			default_relatedcontent.push(related_info['Type'])
		end
	end
	if default_relatedcontent.count > 0
		options['relatedcontent'] = [default_relatedcontent.join(",")]
	end

	return options
end

#did_you_mean(id = "all") ⇒ Object



848
849
850
851
852
853
854
855
856
857
# File 'lib/edsapi_wrapper.rb', line 848

def did_you_mean (id = "all")
	possible_dyms = []
	available_dyms = @info['AvailableSearchCriteria'].fetch('AvailableDidYouMeanOptions',{})
	available_dyms.each do |available_dym|
		if available_dym['Id'] == id || id == "all"
			possible_dyms.push(available_dym)
		end
	end
	return possible_dyms
end

#expanders(id = "all") ⇒ Object



804
805
806
807
808
809
810
811
812
813
# File 'lib/edsapi_wrapper.rb', line 804

def expanders (id = "all")
	possible_expanders = []
	available_expanders = @info['AvailableSearchCriteria'].fetch('AvailableExpanders',{})
	available_expanders.each do |available_expander|
		if available_expander['Id'] == id || id == "all"
			possible_expanders.push(available_expander)
		end
	end
	return possible_expanders
end

#limiters(id = "all") ⇒ Object



815
816
817
818
819
820
821
822
823
824
# File 'lib/edsapi_wrapper.rb', line 815

def limiters (id = "all")
	possible_limiters = []
	available_limiters = @info['AvailableSearchCriteria'].fetch('AvailableLimiters',{})
	available_limiters.each do |available_limiter|
		if available_limiter['Id'] == id || id == "all"
			possible_limiters.push(available_limiter)
		end
	end
	return possible_limiters
end


837
838
839
840
841
842
843
844
845
846
# File 'lib/edsapi_wrapper.rb', line 837

def related_content (id = "all")
	possible_related_contents = []
	available_related_contents = @info['AvailableSearchCriteria'].fetch('AvailableRelatedContent',{})
	available_related_contents.each do |available_related_content|
		if available_related_content['Type'] == id || id == "all"
			possible_related_contents.push(available_related_content)
		end
	end
	return possible_related_contents
end

#results_list_viewObject



863
864
865
# File 'lib/edsapi_wrapper.rb', line 863

def results_list_view
	return @info['ViewResultSettings']['ResultListView']
end

#results_per_pageObject



859
860
861
# File 'lib/edsapi_wrapper.rb', line 859

def results_per_page
	return @info['ViewResultSettings']['ResultsPerPage']
end

#search_fields(id = "all") ⇒ Object



793
794
795
796
797
798
799
800
801
802
# File 'lib/edsapi_wrapper.rb', line 793

def search_fields (id = "all")
	possible_fields = []
	available_fields = @info['AvailableSearchCriteria'].fetch('AvailableSearchFields',{})
	available_fields.each do |available_field|
		if available_field['FieldCode'] == id || id == "all"
			possible_fields.push(available_field)
		end
	end
	return possible_fields
end

#search_modes(id = "all") ⇒ Object



826
827
828
829
830
831
832
833
834
835
# File 'lib/edsapi_wrapper.rb', line 826

def search_modes (id = "all")
	possible_search_modes = []
	available_search_modes = @info['AvailableSearchCriteria'].fetch('AvailableSearchModes',{})
	available_search_modes.each do |available_search_mode|
		if available_search_mode['Mode'] == id || id == "all"
			possible_search_modes.push(available_search_mode)
		end
	end
	return possible_search_modes
end

#sorts(id = "all") ⇒ Object



782
783
784
785
786
787
788
789
790
791
# File 'lib/edsapi_wrapper.rb', line 782

def sorts (id = "all")
	possible_sorts = []
	available_sorts = @info['AvailableSearchCriteria'].fetch('AvailableSorts',{})
	available_sorts.each do |available_sort|
		if available_sort["Id"] == id || id == "all"
			possible_sorts.push(available_sort)
		end
	end
	return possible_sorts
end