Class: TheFuturest::Chapter
- Inherits:
-
Object
- Object
- TheFuturest::Chapter
- Defined in:
- lib/futurest/chapter.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#id ⇒ Object
Returns the value of attribute id.
-
#number ⇒ Object
Returns the value of attribute number.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Chapter
constructor
A new instance of Chapter.
- #paragraphs(query = {}) ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Chapter
Returns a new instance of Chapter.
5 6 7 8 9 |
# File 'lib/futurest/chapter.rb', line 5 def initialize(attrs) @id = attrs["id"] @title = attrs["title"] @number = attrs["number"] end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
3 4 5 |
# File 'lib/futurest/chapter.rb', line 3 def errors @errors end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/futurest/chapter.rb', line 3 def id @id end |
#number ⇒ Object
Returns the value of attribute number.
3 4 5 |
# File 'lib/futurest/chapter.rb', line 3 def number @number end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/futurest/chapter.rb', line 3 def title @title end |
Class Method Details
.find(id, query = {}) ⇒ Object
11 12 13 14 |
# File 'lib/futurest/chapter.rb', line 11 def self.find(id, query = {}) response = Text.get("/chapter/#{id}", :query => query) self.new response.parsed_response end |
Instance Method Details
#paragraphs(query = {}) ⇒ Object
25 26 27 |
# File 'lib/futurest/chapter.rb', line 25 def paragraphs(query = {}) Paragraph.parse Text.get("/chapter/#{@id}/paragraphs", :query => query) end |
#save ⇒ Object
29 30 31 32 33 |
# File 'lib/futurest/chapter.rb', line 29 def save response = Text.post("/chapter/#{@id}", :query => { :title => @title, :number => @number }).parsed_response @errors = response["errors"] and return false if response["errors"].any? true end |