Class: ODDB::FiParse::TextinfoHpricot

Inherits:
Object
  • Object
show all
Defined in:
ext/fiparse/src/textinfo_hpricot.rb

Direct Known Subclasses

FachinfoHpricot, PatinfoHpricot

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#companyObject (readonly)

Returns the value of attribute company.



13
14
15
# File 'ext/fiparse/src/textinfo_hpricot.rb', line 13

def company
  @company
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'ext/fiparse/src/textinfo_hpricot.rb', line 13

def name
  @name
end

Instance Method Details

#chapter(elem) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'ext/fiparse/src/textinfo_hpricot.rb', line 14

def chapter(elem)
  chapter = Text::Chapter.new
  code = nil
  ptr = OpenStruct.new
  ptr.chapter = chapter
  if(title = elem.at("h2"))
    elem.children.delete(title)
    anchor = title.at("a")
    code = anchor['name']
    chapter.heading = text(anchor)
  end
  handle_element(elem, ptr)
  chapter.clean!
  [code, chapter]
end

#extract(doc) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'ext/fiparse/src/textinfo_hpricot.rb', line 29

def extract(doc)
  @name = text(doc.at("h1"))
  @company = simple_chapter(doc.at("div.ownerCompany"))
  @galenic_form = simple_chapter(doc.at("div.shortCharacteristic"))
  (doc/"div.paragraph").each { |elem|
    identify_chapter(*chapter(elem))
  }
  to_textinfo
end