Class: ArticleJSON::Import::GoogleDoc::HTML::TextBoxParser
- Inherits:
-
Object
- Object
- ArticleJSON::Import::GoogleDoc::HTML::TextBoxParser
- Includes:
- Shared::Float
- Defined in:
- lib/article_json/import/google_doc/html/text_box_parser.rb
Instance Method Summary collapse
-
#content ⇒ Array
Parse the text box’s nodes to get a list of sub elements Supported sub elements are: headings, paragraphs & lists.
-
#element ⇒ ArticleJSON::Elements::TextBox
Hash representation of this text box.
-
#initialize(nodes:, css_analyzer:) ⇒ TextBoxParser
constructor
A new instance of TextBoxParser.
Methods included from Shared::Float
Constructor Details
#initialize(nodes:, css_analyzer:) ⇒ TextBoxParser
10 11 12 13 14 15 16 |
# File 'lib/article_json/import/google_doc/html/text_box_parser.rb', line 10 def initialize(nodes:, css_analyzer:) @nodes = nodes.reject { |node| NodeAnalyzer.new(node).empty? } @css_analyzer = css_analyzer # First node of the text box indicates floating behavior @float_node = @nodes.first end |
Instance Method Details
#content ⇒ Array
Parse the text box’s nodes to get a list of sub elements Supported sub elements are: headings, paragraphs & lists.
21 22 23 |
# File 'lib/article_json/import/google_doc/html/text_box_parser.rb', line 21 def content @nodes.map { |node| parse_sub_node(node) }.compact end |
#element ⇒ ArticleJSON::Elements::TextBox
Hash representation of this text box
27 28 29 |
# File 'lib/article_json/import/google_doc/html/text_box_parser.rb', line 27 def element ArticleJSON::Elements::TextBox.new(float: float, content: content) end |