Class: OpenWebslides::Converter::Pressbooks

Inherits:
Object
  • Object
show all
Includes:
Helpers::Sanitization
Defined in:
lib/openwebslides/converter/pressbooks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Sanitization

#sanitize

Instance Attribute Details

#htmlObject

Returns the value of attribute html.



11
12
13
# File 'lib/openwebslides/converter/pressbooks.rb', line 11

def html
  @html
end

#resultObject

Returns the value of attribute result.



11
12
13
# File 'lib/openwebslides/converter/pressbooks.rb', line 11

def result
  @result
end

Instance Method Details

#from_xhtml(html) ⇒ Result

Convert an XHTML document to Open Webslides

Parameters:

  • html (String)

    XHTML document string

Returns:

  • (Result)

    Result object containing all data



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/openwebslides/converter/pressbooks.rb', line 20

def from_xhtml(html)
  @html = Nokogiri::HTML html
  @result = Result.new

  root = Content::Root.new

  

  root.child_item_ids << parse_matter('front').id
  root.child_item_ids.concat parse_parts.map(&:id)
  root.child_item_ids << parse_matter('back').id

  result.content_items << root

  result
end