Class: Kickstapi::Project

Inherits:
Object
  • Object
show all
Includes:
Ghostly
Defined in:
lib/kickstapi/project.rb

Instance Attribute Summary collapse

Attributes included from Ghostly

#data_source, #load_state

Instance Method Summary collapse

Methods included from Ghostly

included, #load

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

#creatorObject

Returns the value of attribute creator.



8
9
10
# File 'lib/kickstapi/project.rb', line 8

def creator
  @creator
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/kickstapi/project.rb', line 8

def id
  @id
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/kickstapi/project.rb', line 8

def name
  @name
end

#urlObject

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_hashObject



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