class TheFuturest::Chapter
Attributes
errors[RW]
id[RW]
number[RW]
title[RW]
Public Class Methods
find(id, query = {})
click to toggle source
# 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
new(attrs)
click to toggle source
# File lib/futurest/chapter.rb, line 5 def initialize(attrs) @id = attrs["id"] @title = attrs["title"] @number = attrs["number"] end
parse(response)
click to toggle source
# File lib/futurest/chapter.rb, line 16 def self.parse(response) chapter = response.parsed_response if chapter.is_a? Array chapter.map {|c| Chapter.new c } else Chapter.new chapter end end
Public Instance Methods
paragraphs(query = {})
click to toggle source
# File lib/futurest/chapter.rb, line 25 def paragraphs(query = {}) Paragraph.parse Text.get("/chapter/#{@id}/paragraphs", :query => query) end
save()
click to toggle source
# 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