Class: Cocoadex::Entity
- Defined in:
- lib/cocoadex/models/entity.rb
Overview
A top level element, roughly equivalent to one page of documentation
Direct Known Subclasses
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Attributes inherited from Element
Instance Method Summary collapse
-
#clean(text) ⇒ Object
Remove leading and trailing whitespace from lines, while stripping HTML tags.
-
#initialize(path) ⇒ Entity
constructor
A new instance of Entity.
- #section_by_title(doc, title) ⇒ Object
- #strip(text) ⇒ Object
Methods inherited from Element
#<=>, #origin, #parse_parameters, #print, #to_s, #type
Methods included from Bri::Templates::Helpers
Constructor Details
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/cocoadex/models/entity.rb', line 5 def path @path end |
Instance Method Details
#clean(text) ⇒ Object
Remove leading and trailing whitespace from lines, while stripping HTML tags
16 17 18 |
# File 'lib/cocoadex/models/entity.rb', line 16 def clean text text.gsub(/(\n|\t|\r)/, ' ').gsub(/>\s*</, '><').squeeze(' ') end |
#section_by_title(doc, title) ⇒ Object
24 25 26 |
# File 'lib/cocoadex/models/entity.rb', line 24 def section_by_title doc, title doc.css("section").to_a.detect {|s| s.css("h2.jump").text == title } end |
#strip(text) ⇒ Object
20 21 22 |
# File 'lib/cocoadex/models/entity.rb', line 20 def strip text text.gsub("  ","") end |