class TheFuturest::Paragraph
Attributes
chapter_id[RW]
errors[RW]
id[RW]
number[RW]
styled_text[RW]
text[RW]
Public Class Methods
new(attrs)
click to toggle source
# File lib/futurest/paragraph.rb, line 5 def initialize(attrs) @id = attrs["id"] @number = attrs["number"] @text = attrs["text"] @styled_text = attrs["styled_text"] @chapter_id = attrs["chapter_id"] end
parse(response)
click to toggle source
# File lib/futurest/paragraph.rb, line 13 def self.parse(response) paragraph = response.parsed_response if paragraph.is_a? Array paragraph.map {|p| Paragraph.new p } else Paragraph.new paragraph end end
Public Instance Methods
chapter()
click to toggle source
# File lib/futurest/paragraph.rb, line 22 def chapter Chapter.parse Text.get("/chapter/#{@chapter_id}") end
save()
click to toggle source
# File lib/futurest/paragraph.rb, line 26 def save response = Text.post("/chapter/#{@chapter_id}/paragraph/#{@id}", :query => { :text => @text, :number => @number }).parsed_response @errors = response["errors"] and return false if response["errors"].any? @styled_text = response["paragraph"]["styled_text"] return true end