Class: Openphar::Parsers::JpHtmlParser
- Inherits:
-
Object
- Object
- Openphar::Parsers::JpHtmlParser
- Defined in:
- lib/openphar/parsers/jp_html_parser.rb
Overview
Parser for Japan Pharmacopoeia HTML monographs
Constant Summary collapse
- SECTION_PATTERNS =
JP monograph section patterns
{ definition: /(?:Definition|Origin and Definition)/i, identification: /Identification/i, purity: /Purity/i, assay: /Assay/i, storage: /Containers and Storage/i }.freeze
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#monographs ⇒ Object
readonly
Returns the value of attribute monographs.
Instance Method Summary collapse
-
#initialize(html_content) ⇒ JpHtmlParser
constructor
A new instance of JpHtmlParser.
-
#parse ⇒ Object
Parse all monographs from the document.
Constructor Details
#initialize(html_content) ⇒ JpHtmlParser
Returns a new instance of JpHtmlParser.
18 19 20 21 |
# File 'lib/openphar/parsers/jp_html_parser.rb', line 18 def initialize(html_content) @document = Nokogiri::HTML(html_content) @monographs = [] end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
16 17 18 |
# File 'lib/openphar/parsers/jp_html_parser.rb', line 16 def document @document end |
#monographs ⇒ Object (readonly)
Returns the value of attribute monographs.
16 17 18 |
# File 'lib/openphar/parsers/jp_html_parser.rb', line 16 def monographs @monographs end |
Instance Method Details
#parse ⇒ Object
Parse all monographs from the document
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/openphar/parsers/jp_html_parser.rb', line 24 def parse # JP HTML structure varies; this is a template monograph_nodes = document.css(".monograph, .crude-drug") monograph_nodes.each do |node| monographs << parse_monograph(node) end monographs end |