Sha256: 4459be11840c7547547310a3cf9edc7e17ea4ad24f63f651cfc9b193274d14df

Contents?: true

Size: 1002 Bytes

Versions: 20

Compression:

Stored size: 1002 Bytes

Contents

class SearchResultRemote
  class MetaInformation
    attr_reader :key, :value

    def initialize(key, value)
      @key = key
      @value = value
    end
  end

  attr_reader :label, :host, :path, :meta
  attr_accessor :body, :rdf_namespace, :rdf_predicate, :language

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

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

  def url
    host + path
  end

  def search_result_partial_name
    'search_results/search_result_remote'
  end

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

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

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

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

  def to_s
    @label
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
iqvoc-4.14.5 app/presenters/search_result_remote.rb
iqvoc-4.14.4 app/presenters/search_result_remote.rb
iqvoc-4.13.2 app/presenters/search_result_remote.rb
iqvoc-4.13.0 app/presenters/search_result_remote.rb
iqvoc-4.12.1 app/presenters/search_result_remote.rb
iqvoc-4.12.0 app/presenters/search_result_remote.rb
iqvoc-4.11.1 app/presenters/search_result_remote.rb
iqvoc-4.11.0 app/presenters/search_result_remote.rb
iqvoc-4.10.0 app/presenters/search_result_remote.rb
iqvoc-4.9.0 app/presenters/search_result_remote.rb
iqvoc-4.8.2 app/presenters/search_result_remote.rb
iqvoc-4.8.1 app/presenters/search_result_remote.rb
iqvoc-4.8.0 app/presenters/search_result_remote.rb
iqvoc-4.7.0 app/presenters/search_result_remote.rb
iqvoc-4.6.1 app/presenters/search_result_remote.rb
iqvoc-4.5.2 app/presenters/search_result_remote.rb
iqvoc-4.6.0 app/presenters/search_result_remote.rb
iqvoc-4.5.1 app/presenters/search_result_remote.rb
iqvoc-4.5.0 app/presenters/search_result_remote.rb
iqvoc-4.4.0 app/presenters/search_result_remote.rb