Module: MiscProcess

Included in:
IndexManager, IndexManager, MultiDataset
Defined in:
lib/misc_process.rb

Instance Method Summary collapse

Instance Method Details

#gen_class_name(dataspec) ⇒ Object

Generates properly formatted class name



3
4
5
# File 'lib/misc_process.rb', line 3

def gen_class_name(dataspec)
  return dataspec.index_name.split("_").map{ |c| c.capitalize}.join+"Doc"
end

#make_facet_version(f, item, dataspec) ⇒ Object

Creates a facet version with the same value for field



21
22
23
24
25
26
27
28
29
30
# File 'lib/misc_process.rb', line 21

def make_facet_version(f, item, dataspec)
  if dataspec.facet_fields.include?(f["Field Name"])
    field_name = f["Field Name"]
    facet_field_name = f["Field Name"]+"_facet"

    item[facet_field_name.to_sym] = item[set_name(field_name, item)]
  end
  
  return item
end

#process_pic(f, item, dataspec) ⇒ Object

Adds the specified prefix to the images



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/misc_process.rb', line 8

def process_pic(f, item, dataspec)
  if f["Field Name"] == "picture"
    pic_field = f["Field Name"]

    if !dataspec.image_prefix.empty?
      item[pic_field] = dataspec.image_prefix+item[pic_field].split("/").last
    end
  end

  return item
end

#set_name(f, item) ⇒ Object

Set field name as symbol or string as needed



33
34
35
36
37
# File 'lib/misc_process.rb', line 33

def set_name(f, item)
  field_name = f.to_sym
  field_name = item[field_name] == nil ? field_name.to_s : field_name
  return field_name
end