Class: CatEngine::FlatEngine

Inherits:
Object
  • Object
show all
Defined in:
lib/cat_engine/flat_engine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_history = []) ⇒ FlatEngine

Returns a new instance of FlatEngine.



6
7
8
# File 'lib/cat_engine/flat_engine.rb', line 6

def initialize full_history = []
  self.full_history = full_history
end

Instance Attribute Details

#full_historyObject

Returns the value of attribute full_history.



9
10
11
# File 'lib/cat_engine/flat_engine.rb', line 9

def full_history
  @full_history
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/cat_engine/flat_engine.rb', line 9

def id
  @id
end

Instance Method Details

#process(id, history) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cat_engine/flat_engine.rb', line 11

def process id, history
  self.id = id

  doc = Nokogiri.parse(form)
  item = doc.root.css("Item").reject do |item|
    full_history.include?(item["FormItemOID"])
  end.first

  doc.root.children.each(&:unlink)
  if item
    item.parent = doc.root
  else
    doc.root = doc.create_element("Results")
  end

  doc
end

#valid_history?(id, history) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/cat_engine/flat_engine.rb', line 29

def valid_history? id, history
  true
end