class MARCSpec::ConstantSolrSpec
A ConstantSolrSpec
always returns the same value(s) no matter what's in the record.
Attributes
constantValue[RW]
Public Class Methods
fromHash(h)
click to toggle source
Build up from a ruby hash @deprecated Use the DSL
# File lib/marcspec/constantspec.rb, line 40 def self.fromHash h return self.new(h) end
new(opts = {})
click to toggle source
# File lib/marcspec/constantspec.rb, line 11 def initialize opts = {} @solrField = opts[:solrField] @constantValue = opts[:constantValue] @arity = 1 # Check to make sure we didn't get anything else and warn if need be [:firstOnly, :mapname, :noMapKeyDefault, :specs, :default, :module, :functionSymbol].each do |s| if opts[s] raise ArgumentError, "#{s} is not a valid option for Constant spec (one with :constantValue defined)" end end end
Public Instance Methods
==(other)
click to toggle source
Basic equality
# File lib/marcspec/constantspec.rb, line 34 def == other return @constantValue == other.constantValue end
asDSLString()
click to toggle source
# File lib/marcspec/constantspec.rb, line 44 def asDSLString return "constant('#{@solrField}') do\n value #{@constantValue.inspect}\nend" end
asPPString()
click to toggle source
Used to round-trip to/from hash syntax @deprecated Use the DSL
# File lib/marcspec/constantspec.rb, line 50 def asPPString s = StringIO.new s.print "{\n :solrField=> " PP.singleline_pp(@solrField, s) s.print(",\n ") s.print ":constantValue => " PP.singleline_pp(@constantValue, s) s.print "\n}" return s.string end
marc_values(r, doc = {})
click to toggle source
Return the constant value associated with this spec @param [MARC4J4R::Record] r The record. IGNORED. It's a constant ;-) @param [Hash, SolrInputDocument] doc The hash-like object that contains previously-generated content. IGNORED @return [String, Array] The constant value(s) associated with this object.
# File lib/marcspec/constantspec.rb, line 29 def marc_values r, doc = {} return @constantValue end
value(val)
click to toggle source
# File lib/marcspec/dsl.rb, line 167 def value(val) self.constantValue = val end