Class: XTF::Search::Element::Facet
- Defined in:
- lib/xtf/search/element/facet.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(*args) ⇒ Facet
constructor
can take a String or Symbol as first argument for required attribute #field.
- #to_xml ⇒ Object
- #to_xml_node ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(*args) ⇒ Facet
can take a String or Symbol as first argument for required attribute #field
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/xtf/search/element/facet.rb', line 5 def initialize(*args) @tag_name = "facet" @field = args.shift.to_s if args[0].is_a?(String) or args[0].is_a?(Symbol) params = args[0] || {} raise ArgumentError, "supply field as first argument or as attribute of Hash, but not both!" if @field && params.key?(:field) @field = params.delete(:field) unless @field raise ArgumentError, "field is required." unless @field super end |
Instance Method Details
#to_xml ⇒ Object
22 23 24 |
# File 'lib/xtf/search/element/facet.rb', line 22 def to_xml to_xml_node.to_s end |