Class: Raev::Article

Inherits:
Object
  • Object
show all
Defined in:
lib/raev/article.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ Article

Returns a new instance of Article.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/raev/article.rb', line 8

def initialize(body)
  body = replace_non_breaking_space(body)
  
  @doc = Nokogiri::HTML::DocumentFragment.parse(body)
  
  @doc = replace_divs_with_paragraphs(@doc)
  @doc = remove_empty_paragraphs(@doc)
  @doc = remove_extra_linebreaks(@doc)

  @body = @doc.to_s.gsub("\n", "")
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/raev/article.rb', line 5

def body
  @body
end

#docObject (readonly)

Returns the value of attribute doc.



6
7
8
# File 'lib/raev/article.rb', line 6

def doc
  @doc
end