Class: Pho::FieldWeighting

Inherits:
Object
  • Object
show all
Defined in:
lib/pho/query_profile.rb

Overview

Captures the details of a weighted field from a QueryProfile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, name, weight) ⇒ FieldWeighting

Returns a new instance of FieldWeighting.



15
16
17
18
19
# File 'lib/pho/query_profile.rb', line 15

def initialize(uri, name, weight)
  @uri = uri
  @name = name
  @weight = weight
end

Instance Attribute Details

#nameObject (readonly)

The name of the field being weighted



10
11
12
# File 'lib/pho/query_profile.rb', line 10

def name
  @name
end

#uriObject (readonly)

The uri of the field weighting



7
8
9
# File 'lib/pho/query_profile.rb', line 7

def uri
  @uri
end

#weightObject (readonly)

The weighting applied to the field



13
14
15
# File 'lib/pho/query_profile.rb', line 13

def weight
  @weight
end

Instance Method Details

#to_rdf(ns = true) ⇒ Object

Convert this object into an RDF representation. Generates a simple rdf:Description, optionally including namespaces

ns

include namespace declarations



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pho/query_profile.rb', line 23

def to_rdf(ns=true)
  rdf = "<rdf:Description " 
  if ns
    rdf << " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:frm=\"#{Pho::Namespaces::FRAME}\" xmlns:bf=\"#{Pho::Namespaces::CONFIG}\" "        
  end 
  rdf << " rdf:about=\"#{@uri}\">"
  rdf << " <frm:name>#{@name}</frm:name>"      
  rdf << " <bf:weight>#{@weight}</bf:weight>"      
  rdf << "</rdf:Description>"
  return rdf  
end