Class: Scrapbox::Page

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, title) ⇒ Page

Returns a new instance of Page.



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

def initialize(project,title)
  @project = project
  @title = title
  @text = nil
  @code = nil
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



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

def project
  @project
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#code(src) ⇒ Object



20
21
22
23
24
25
# File 'lib/scrapbox/page.rb', line 20

def code(src)
  unless @code
    @code = Scrapbox.__getsbdata("#{project.host}/api/code/#{project.name}/#{URI.encode(title)}/#{src}")
  end
  @code
end

#textObject



13
14
15
16
17
18
# File 'lib/scrapbox/page.rb', line 13

def text
  unless @text
    @text = Scrapbox.__getsbdata("#{project.host}/api/pages/#{project.name}/#{URI.encode(title).gsub(/\//,'%2f')}/text")
  end
  @text
end