Class: EDSApi::EDSAPIInfo
- Inherits:
-
Object
- Object
- EDSApi::EDSAPIInfo
- Defined in:
- lib/edsapi_wrapper.rb
Instance Attribute Summary collapse
-
#info ⇒ Object
Returns the value of attribute info.
Instance Method Summary collapse
- #default_options ⇒ Object
- #did_you_mean(id = "all") ⇒ Object
- #expanders(id = "all") ⇒ Object
-
#initialize(info_raw) ⇒ EDSAPIInfo
constructor
A new instance of EDSAPIInfo.
- #limiters(id = "all") ⇒ Object
- #related_content(id = "all") ⇒ Object
- #results_list_view ⇒ Object
- #results_per_page ⇒ Object
- #search_fields(id = "all") ⇒ Object
- #search_modes(id = "all") ⇒ Object
- #sorts(id = "all") ⇒ Object
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
#info ⇒ Object
Returns the value of attribute info.
776 777 778 |
# File 'lib/edsapi_wrapper.rb', line 776 def info @info end |
Instance Method Details
#default_options ⇒ Object
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 = {} self.search_modes.each do |search_mode| if search_mode['DefaultOn'] == "y" ['searchmode'] = [search_mode['Mode']] end end ['resultsperpage'] = [self.results_per_page] ['sort'] = ['relevance'] ['view'] = [self.results_list_view] ['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 ['limiter'] = default_limiters end = [] self..each do || if ['DefaultOn'] == 'y' .push(['Id']) end end if .count > 0 ['expander'] = end = [] self..each do || if ['DefaultOn'] == 'y' .push(['Type']) end end if .count > 0 ['relatedcontent'] = [.join(",")] end return 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 (id = "all") = [] = @info['AvailableSearchCriteria'].fetch('AvailableExpanders',{}) .each do || if ['Id'] == id || id == "all" .push() end end return 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 |
#related_content(id = "all") ⇒ Object
837 838 839 840 841 842 843 844 845 846 |
# File 'lib/edsapi_wrapper.rb', line 837 def (id = "all") = [] = @info['AvailableSearchCriteria'].fetch('AvailableRelatedContent',{}) .each do || if ['Type'] == id || id == "all" .push() end end return end |
#results_list_view ⇒ Object
863 864 865 |
# File 'lib/edsapi_wrapper.rb', line 863 def results_list_view return @info['ViewResultSettings']['ResultListView'] end |
#results_per_page ⇒ Object
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 |