Class: ActiveDocument::MarkLogicSearchOptions
- Inherits:
-
Object
- Object
- ActiveDocument::MarkLogicSearchOptions
- Defined in:
- lib/ActiveDocument/mark_logic_search_options.rb
Defined Under Namespace
Classes: ComputedBucket
Instance Attribute Summary collapse
-
#range_constraints ⇒ Object
Returns the value of attribute range_constraints.
-
#return_facets ⇒ Object
Returns the value of attribute return_facets.
-
#value_constraints ⇒ Object
Returns the value of attribute value_constraints.
-
#word_constraints ⇒ Object
Returns the value of attribute word_constraints.
Instance Method Summary collapse
-
#initialize ⇒ MarkLogicSearchOptions
constructor
A new instance of MarkLogicSearchOptions.
-
#to_s ⇒ Object
outputs the object in correctly formatted XML suitable for use in a search.
Constructor Details
#initialize ⇒ MarkLogicSearchOptions
Returns a new instance of MarkLogicSearchOptions.
25 26 27 28 29 30 |
# File 'lib/ActiveDocument/mark_logic_search_options.rb', line 25 def initialize @return_facets = true; @value_constraints = Hash.new @word_constraints = Hash.new @range_constraints = Hash.new end |
Instance Attribute Details
#range_constraints ⇒ Object
Returns the value of attribute range_constraints.
23 24 25 |
# File 'lib/ActiveDocument/mark_logic_search_options.rb', line 23 def range_constraints @range_constraints end |
#return_facets ⇒ Object
Returns the value of attribute return_facets.
23 24 25 |
# File 'lib/ActiveDocument/mark_logic_search_options.rb', line 23 def return_facets @return_facets end |
#value_constraints ⇒ Object
Returns the value of attribute value_constraints.
23 24 25 |
# File 'lib/ActiveDocument/mark_logic_search_options.rb', line 23 def value_constraints @value_constraints end |
#word_constraints ⇒ Object
Returns the value of attribute word_constraints.
23 24 25 |
# File 'lib/ActiveDocument/mark_logic_search_options.rb', line 23 def word_constraints @word_constraints end |
Instance Method Details
#to_s ⇒ Object
outputs the object in correctly formatted XML suitable for use in a search
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/ActiveDocument/mark_logic_search_options.rb', line 34 def to_s constraints = String.new @value_constraints.each do |key, value| constraints << <<-XML <constraint name="#{key.gsub(/\s/, '_')}"> <value> <element ns="#{value["namespace"]}" name="#{value["element"]}"/> </value> </constraint> XML end @word_constraints.each do |key, value| constraints << <<-XML <constraint name="#{key.gsub(/\s/, '_')}"> <word> <element ns="#{value["namespace"]}" name="#{value["element"]}"/> </word> </constraint> XML end @range_constraints.each do |key, value| constraints << <<-XML <constraint name="#{key.gsub(/\s/, '_')}"> <range type="#{value["type"]}" XML if value.has_key?("collation") constraints << "collation=\"#{value["collation"]}\"" end constraints << <<-XML > <element ns="#{value["namespace"]}" name="#{value["element"]}"/> XML if value.has_key?("computed_buckets") value["computed_buckets"].each do |computed_bucket| constraints << computed_bucket.to_s if computed_bucket.instance_of?(ActiveDocument::MarkLogicSearchOptions::ComputedBucket) end end constraints << "</range></constraint>" end value = <<-XML <options xmlns="http://marklogic.com/appservices/search"> <return-facets>#{@return_facets}</return-facets> XML # add in constraints unless constraints.empty? value << constraints end # close the options node value << "</options>" end |