Class: Nwiki::Core::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/nwiki/core/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, doc, parser_class) ⇒ Page

Returns a new instance of Page.



6
7
8
9
10
11
# File 'lib/nwiki/core/page.rb', line 6

def initialize title, doc, parser_class
  raise 'title is empty or nil' unless title
  raise 'doc is empty or nil' unless doc
  raise 'parser_class is empty or nil' unless parser_class
  @title, @doc, @parser_class = title, doc, parser_class
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



4
5
6
# File 'lib/nwiki/core/page.rb', line 4

def doc
  @doc
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'lib/nwiki/core/page.rb', line 4

def title
  @title
end

Instance Method Details

#==(other) ⇒ Object



21
22
23
24
25
# File 'lib/nwiki/core/page.rb', line 21

def == other
  return false unless other
  self.kind_of?(other.class) &&
  self.doc == other.doc
end

#encodingObject



13
14
15
# File 'lib/nwiki/core/page.rb', line 13

def encoding
  @doc.encoding
end

#to_htmlObject



17
18
19
# File 'lib/nwiki/core/page.rb', line 17

def to_html
  @parser_class.new(@doc, offset: 1).to_html
end