Class: Diggr::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/diggr/response_classes/container.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContainer

Returns a new instance of Container.



9
10
11
# File 'lib/diggr/response_classes/container.rb', line 9

def initialize
  self.topics = []
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/diggr/response_classes/container.rb', line 7

def name
  @name
end

#short_nameObject

Returns the value of attribute short_name.



7
8
9
# File 'lib/diggr/response_classes/container.rb', line 7

def short_name
  @short_name
end

#topicsObject

Returns the value of attribute topics.



7
8
9
# File 'lib/diggr/response_classes/container.rb', line 7

def topics
  @topics
end

Class Method Details

.new_from_parsed_json(data) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/diggr/response_classes/container.rb', line 13

def self.new_from_parsed_json(data)
  container = Container.new
  container.name = data['name']
  container.short_name = data['short_name']
  
  if data.has_key? 'topics'
    data['topics'].each do | topic_data |
      container.topics << Topic.new_from_parsed_json(topic_data)
    end
  end

  container
end