Module: Parliament::Utils::Helpers::FilterHelper
- Defined in:
- lib/parliament/utils/helpers/filter_helper.rb
Class Method Summary collapse
-
.filter(request, *types) ⇒ Parliament::Response::NTripleResponse
Takes a request object and a variable amount of types for filtering, gets types_to_filter using #filter_types method, and calls RequestHelper.filter_response_data to return filtered NTriple Object.
-
.filter_sort(request, sort_type, type, letters) ⇒ Parliament::Response::NTripleResponse
Takes a request, sort type, type to sort and letters to sort by.
-
.filter_types(*types) ⇒ Array
Takes variable amount of types for filtering, checks if type is ‘ordnance’, and returns array of types to filter.
Class Method Details
.filter(request, *types) ⇒ Parliament::Response::NTripleResponse
Takes a request object and a variable amount of types for filtering, gets types_to_filter using #filter_types method, and calls RequestHelper.filter_response_data to return filtered NTriple Object
12 13 14 15 16 17 |
# File 'lib/parliament/utils/helpers/filter_helper.rb', line 12 def self.filter(request, *types) types_to_filter = filter_types(*types) Parliament::Utils::Helpers::RequestHelper.filter_response_data( request, *types_to_filter ) end |
.filter_sort(request, sort_type, type, letters) ⇒ Parliament::Response::NTripleResponse
Takes a request, sort type, type to sort and letters to sort by. Calls the #filter method to define type and letters Sorts type by sort type Maps letters using #value Returns type and letters
48 49 50 51 52 53 |
# File 'lib/parliament/utils/helpers/filter_helper.rb', line 48 def self.filter_sort(request, sort_type, type, letters) type, letters = filter(request, type, letters) type = type.sort_by(sort_type) letters = letters.map(&:value) [type, letters] end |
.filter_types(*types) ⇒ Array
Takes variable amount of types for filtering, checks if type is ‘ordnance’, and returns array of types to filter
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/parliament/utils/helpers/filter_helper.rb', line 24 def self.filter_types(*types) types_to_filter = [] types.each do |type| if type == ::Grom::Node::BLANK types_to_filter << ::Grom::Node::BLANK else type == 'ordnance' ? types_to_filter << 'http://data.ordnancesurvey.co.uk/ontology/admingeo/EuropeanRegion' : types_to_filter << Parliament::Utils::Helpers::RequestHelper.namespace_uri_schema_path(type) end end types_to_filter end |