Class: Archivist::Client::Filters

Inherits:
Object
  • Object
show all
Defined in:
lib/archivist/client/filters.rb

Overview

Filters class manages the available filters that are configured to work with Archive.org The public API is very simple, and is used to create Archive.org query strings:

filters = Filters.new(options)
query = filters.to_query

Defined Under Namespace

Classes: FilterException

Constant Summary collapse

STANDARD_OPTIONS =
[
  :filters,
  :language,
  :start_year, :end_year,
  :identifier
]
DEFAULT_FILTERS =
[
  'mediatype:texts',
  '-mediatype:collection'
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Filters

Returns a new instance of Filters.



28
29
30
31
# File 'lib/archivist/client/filters.rb', line 28

def initialize(opts)
  @options = {}
  self.update(opts)
end

Instance Attribute Details

#end_yearObject

Returns the value of attribute end_year.



23
24
25
# File 'lib/archivist/client/filters.rb', line 23

def end_year
  @end_year
end

#filtersObject

Returns the value of attribute filters.



23
24
25
# File 'lib/archivist/client/filters.rb', line 23

def filters
  @filters
end

#languageObject

Returns the value of attribute language.



23
24
25
# File 'lib/archivist/client/filters.rb', line 23

def language
  @language
end

#optionsObject

Returns the value of attribute options.



23
24
25
# File 'lib/archivist/client/filters.rb', line 23

def options
  @options
end

#start_yearObject

Returns the value of attribute start_year.



23
24
25
# File 'lib/archivist/client/filters.rb', line 23

def start_year
  @start_year
end

Instance Method Details

#update(opts) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/archivist/client/filters.rb', line 33

def update(opts)
  self.prune_options(opts)
  self.set_language
  self.set_years
  self.set_identifier
  self.set_filters
end