Class: Kickstapi::Project
- Inherits:
-
Object
- Object
- Kickstapi::Project
- Includes:
- Ghostly
- Defined in:
- lib/kickstapi/project.rb
Instance Attribute Summary collapse
-
#creator ⇒ Object
Returns the value of attribute creator.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
Attributes included from Ghostly
Instance Method Summary collapse
- #==(other) ⇒ Object
- #complete(attributes) ⇒ Object
-
#initialize(attributes = {}) ⇒ Project
constructor
A new instance of Project.
- #rewards=(rewards) ⇒ Object
- #to_hash ⇒ Object
- #to_json(*a) ⇒ Object
Methods included from Ghostly
Constructor Details
#initialize(attributes = {}) ⇒ Project
Returns a new instance of Project.
14 15 16 |
# File 'lib/kickstapi/project.rb', line 14 def initialize(attributes = {}) complete(attributes) end |
Instance Attribute Details
#creator ⇒ Object
Returns the value of attribute creator.
8 9 10 |
# File 'lib/kickstapi/project.rb', line 8 def creator @creator end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/kickstapi/project.rb', line 8 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/kickstapi/project.rb', line 8 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/kickstapi/project.rb', line 8 def url @url end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 |
# File 'lib/kickstapi/project.rb', line 31 def ==(other) other.is_a?(Project) && other.id == id end |
#complete(attributes) ⇒ Object
18 19 20 21 22 |
# File 'lib/kickstapi/project.rb', line 18 def complete(attributes) attributes.each do |key, value| public_send("#{key}=", value) end end |
#rewards=(rewards) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/kickstapi/project.rb', line 24 def rewards=(rewards) @rewards = [] rewards.each do |reward| @rewards << Kickstapi::Reward.new(reward) end end |
#to_hash ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/kickstapi/project.rb', line 35 def to_hash hash = {} self.instance_variables.each do |var| sym = var.to_s.gsub(/@/, '') next if ['load_state', 'data_source'].include? sym hash[sym.to_sym] = self.instance_variable_get var end hash end |
#to_json(*a) ⇒ Object
45 46 47 |
# File 'lib/kickstapi/project.rb', line 45 def to_json(*a) self.to_hash.to_json end |