Class: SearchResultRemote

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/search_result_remote.rb

Defined Under Namespace

Classes: MetaInformation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, path, label) ⇒ SearchResultRemote

Returns a new instance of SearchResultRemote.



14
15
16
17
18
19
# File 'app/presenters/search_result_remote.rb', line 14

def initialize(host, path, label)
  @host = host
  @path = path
  @label = label.to_s.squish
  @meta = []
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



12
13
14
# File 'app/presenters/search_result_remote.rb', line 12

def body
  @body
end

#hostObject (readonly)

Returns the value of attribute host.



11
12
13
# File 'app/presenters/search_result_remote.rb', line 11

def host
  @host
end

#labelObject (readonly)

Returns the value of attribute label.



11
12
13
# File 'app/presenters/search_result_remote.rb', line 11

def label
  @label
end

#languageObject

Returns the value of attribute language.



12
13
14
# File 'app/presenters/search_result_remote.rb', line 12

def language
  @language
end

#metaObject (readonly)

Returns the value of attribute meta.



11
12
13
# File 'app/presenters/search_result_remote.rb', line 11

def meta
  @meta
end

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'app/presenters/search_result_remote.rb', line 11

def path
  @path
end

#rdf_namespaceObject

Returns the value of attribute rdf_namespace.



12
13
14
# File 'app/presenters/search_result_remote.rb', line 12

def rdf_namespace
  @rdf_namespace
end

#rdf_predicateObject

Returns the value of attribute rdf_predicate.



12
13
14
# File 'app/presenters/search_result_remote.rb', line 12

def rdf_predicate
  @rdf_predicate
end

Instance Method Details

#add_meta_information(key, value) ⇒ Object



21
22
23
# File 'app/presenters/search_result_remote.rb', line 21

def add_meta_information(key, value)
  @meta << MetaInformation.new(key, value)
end

#build_rdf(document, subject) ⇒ Object



37
38
39
40
41
42
# File 'app/presenters/search_result_remote.rb', line 37

def build_rdf(document, subject)
  predicate = URI.parse(rdf_predicate_uri)
  value = body || label

  subject.build_full_uri_predicate(predicate, value, lang: language)
end

#build_search_result_rdf(document, result) ⇒ Object



44
45
46
47
# File 'app/presenters/search_result_remote.rb', line 44

def build_search_result_rdf(document, result)
  result.Sdc::link(url)
  build_rdf(document, result)
end

#rdf_predicate_uriObject



33
34
35
# File 'app/presenters/search_result_remote.rb', line 33

def rdf_predicate_uri
  rdf_namespace.try(:+, rdf_predicate)
end

#search_result_partial_nameObject



29
30
31
# File 'app/presenters/search_result_remote.rb', line 29

def search_result_partial_name
  'search_results/search_result_remote'
end

#to_sObject



49
50
51
# File 'app/presenters/search_result_remote.rb', line 49

def to_s
  @label
end

#urlObject



25
26
27
# File 'app/presenters/search_result_remote.rb', line 25

def url
  host + path
end