Module: Solrizer::DefaultDescriptors::Normal

Constant Summary collapse

SHORT_REPO =
"ldpd.short.repo"
LONG_REPO =
"ldpd.long.repo"
FULL_REPO =
"ldpd.full.repo"
SHORT_PROJ =
"ldpd.short.project"
FULL_PROJ =
"ldpd.full.project"

Instance Method Summary collapse

Instance Method Details

#normal(value) ⇒ Object



78
79
80
# File 'lib/cul_hydra/solrizer_patch.rb', line 78

def normal(value)
  normal!(value.clone)
end

#normal!(value) ⇒ Object



81
82
83
84
85
# File 'lib/cul_hydra/solrizer_patch.rb', line 81

def normal!(value)
  value.gsub!(/\s+/,' ')
  value.strip!
  value
end

#translate_with_default(prefix, value, default) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/cul_hydra/solrizer_patch.rb', line 86

def translate_with_default(prefix, value, default)
  begin
    # Using method below to handle translations because our YAML keys can contain periods and this doesn't play well with the translation dot-syntax
    translations = HashWithIndifferentAccess.new(I18n.t(prefix))
    if translations.has_key?(value)
      return translations[value]
    else
      return default
    end
  rescue
    return default
  end
end