Class: Slurper::Story

Inherits:
Object
  • Object
show all
Defined in:
lib/slurper/story.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject

Returns the value of attribute attributes.



6
7
8
# File 'lib/slurper/story.rb', line 6

def attributes
  @attributes
end

Instance Method Details

#descriptionObject



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_messageObject



19
# File 'lib/slurper/story.rb', line 19

def error_message; @response.body end

#nameObject



21
# File 'lib/slurper/story.rb', line 21

def name;       attributes[:name]       end

#to_post_paramsObject



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

Returns:

  • (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