Class: OpenStax::Cnx::V1::Paragraph

Inherits:
Element
  • Object
show all
Defined in:
lib/openstax/cnx/v1/paragraph.rb

Constant Summary collapse

MATCH_PARAGRAPH =
'//p[@id]'

Instance Attribute Summary

Attributes inherited from Element

#node

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node:) ⇒ Paragraph

Returns a new instance of Paragraph.



5
6
7
# File 'lib/openstax/cnx/v1/paragraph.rb', line 5

def initialize(node:)
  super
end

Class Method Details

.matcherObject



17
18
19
# File 'lib/openstax/cnx/v1/paragraph.rb', line 17

def self.matcher
  MATCH_PARAGRAPH
end

.matches?(node) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/openstax/cnx/v1/paragraph.rb', line 21

def self.matches?(node)
  node.matches?(MATCH_PARAGRAPH)
end

Instance Method Details

#idObject



13
14
15
# File 'lib/openstax/cnx/v1/paragraph.rb', line 13

def id
  node.attr('id')
end

#textObject



9
10
11
# File 'lib/openstax/cnx/v1/paragraph.rb', line 9

def text
  node.text
end