Class: Scrapbox::Project
- Inherits:
-
Object
- Object
- Scrapbox::Project
- Defined in:
- lib/scrapbox/project.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, host = 'https://scrapbox.io') ⇒ Project
constructor
A new instance of Project.
- #pages ⇒ Object
- #titles ⇒ Object
Constructor Details
#initialize(name, host = 'https://scrapbox.io') ⇒ Project
Returns a new instance of Project.
6 7 8 9 10 11 |
# File 'lib/scrapbox/project.rb', line 6 def initialize(name,host='https://scrapbox.io') @name = name @host = host @titles = nil @pages = nil end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
4 5 6 |
# File 'lib/scrapbox/project.rb', line 4 def host @host end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/scrapbox/project.rb', line 4 def name @name end |
Instance Method Details
#pages ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/scrapbox/project.rb', line 23 def pages unless @pages @pages = {} titles.each { |title| page = Scrapbox::Page.new(self,title) @pages[title] = page } end @pages end |
#titles ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/scrapbox/project.rb', line 13 def titles data = Scrapbox.__getsbdata("#{@host}/api/pages/#{@name}") unless @titles @titles = JSON.parse(data)['pages'].collect { |page| page['title'] } end @titles end |