Class: TheFuturest::Paragraph
- Inherits:
-
Object
- Object
- TheFuturest::Paragraph
- Defined in:
- lib/futurest/paragraph.rb
Instance Attribute Summary collapse
-
#chapter_id ⇒ Object
Returns the value of attribute chapter_id.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#id ⇒ Object
Returns the value of attribute id.
-
#number ⇒ Object
Returns the value of attribute number.
-
#styled_text ⇒ Object
Returns the value of attribute styled_text.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #chapter ⇒ Object
-
#initialize(attrs) ⇒ Paragraph
constructor
A new instance of Paragraph.
- #save ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Paragraph
Returns a new instance of Paragraph.
5 6 7 8 9 10 11 |
# 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 |
Instance Attribute Details
#chapter_id ⇒ Object
Returns the value of attribute chapter_id.
3 4 5 |
# File 'lib/futurest/paragraph.rb', line 3 def chapter_id @chapter_id end |
#errors ⇒ Object
Returns the value of attribute errors.
3 4 5 |
# File 'lib/futurest/paragraph.rb', line 3 def errors @errors end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/futurest/paragraph.rb', line 3 def id @id end |
#number ⇒ Object
Returns the value of attribute number.
3 4 5 |
# File 'lib/futurest/paragraph.rb', line 3 def number @number end |
#styled_text ⇒ Object
Returns the value of attribute styled_text.
3 4 5 |
# File 'lib/futurest/paragraph.rb', line 3 def styled_text @styled_text end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/futurest/paragraph.rb', line 3 def text @text end |
Class Method Details
Instance Method Details
#chapter ⇒ Object
22 23 24 |
# File 'lib/futurest/paragraph.rb', line 22 def chapter Chapter.parse Text.get("/chapter/#{@chapter_id}") end |
#save ⇒ Object
26 27 28 29 30 31 |
# 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 |