Class: Slurper::Story
- Inherits:
-
Object
- Object
- Slurper::Story
- Defined in:
- lib/slurper/story.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Instance Method Summary collapse
- #description ⇒ Object
- #error_message ⇒ Object
-
#initialize(attrs = {}) ⇒ Story
constructor
A new instance of Story.
- #name ⇒ Object
- #to_post_params ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(attrs = {}) ⇒ Story
Returns a new instance of Story.
7 8 9 |
# File 'lib/slurper/story.rb', line 7 def initialize(attrs={}) self.attributes = (attrs || {}).symbolize_keys end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/slurper/story.rb', line 6 def attributes @attributes end |
Instance Method Details
#description ⇒ Object
23 24 25 26 |
# File 'lib/slurper/story.rb', line 23 def description return nil unless attributes[:description].present? attributes[:description].split("\n").map(&:strip).join("\n") end |
#error_message ⇒ Object
19 |
# File 'lib/slurper/story.rb', line 19 def ; @response.body end |
#name ⇒ Object
21 |
# File 'lib/slurper/story.rb', line 21 def name; attributes[:name] end |
#to_post_params ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/slurper/story.rb', line 11 def to_post_params { name: name, desc: description, due: nil } end |
#valid? ⇒ Boolean
28 29 30 31 32 |
# File 'lib/slurper/story.rb', line 28 def valid? if name.blank? raise "Name is blank for story:\n#{to_json}" end end |