Class: Page

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

Constant Summary collapse

TYPE =
'page'
REPRESENTATION =
'storage'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(space_key, title, document, page_id) ⇒ Page

Returns a new instance of Page.



10
11
12
13
14
15
16
# File 'lib/asciidoctor/page.rb', line 10

def initialize(space_key, title, document, page_id)
  @space_key = space_key
  @title = title
  @document = document
  @page_id = page_id
  @revision = nil
end

Instance Attribute Details

#page_idObject (readonly)

Returns the value of attribute page_id.



7
8
9
# File 'lib/asciidoctor/page.rb', line 7

def page_id
  @page_id
end

#revision=(value) ⇒ Object (writeonly)

Sets the attribute revision

Parameters:

  • value

    the value to set the attribute revision to.



8
9
10
# File 'lib/asciidoctor/page.rb', line 8

def revision=(value)
  @revision = value
end

#space_keyObject (readonly)

Returns the value of attribute space_key.



7
8
9
# File 'lib/asciidoctor/page.rb', line 7

def space_key
  @space_key
end

#titleObject (readonly)

Returns the value of attribute title.



7
8
9
# File 'lib/asciidoctor/page.rb', line 7

def title
  @title
end

Instance Method Details

#to_jsonObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/asciidoctor/page.rb', line 18

def to_json
  page = {
      :type => TYPE,
      :title => @title,
      :space => {
          :key => @space_key
      },
      :body => {
          :storage => {
              :value => @document,
              :representation => REPRESENTATION
          }
      }
  }

  page[:version] = {:number => @revision} unless @revision.nil?
  page[:id] = @page_id unless @page_id.nil?

  JSON.generate page
end