Class: World

Inherits:
Object
  • Object
show all
Defined in:
lib/asker/data/world.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(concepts, internet = true) ⇒ World

Returns a new instance of World.



8
9
10
11
12
# File 'lib/asker/data/world.rb', line 8

def initialize(concepts, internet = true)
  find_neighbors_for_every_concept(concepts)
  @concepts, @filenames, @contexts = get_lists_from(concepts)
  @image_urls = find_url_images_from_internet(internet)
end

Instance Attribute Details

#conceptsObject (readonly)

Returns the value of attribute concepts.



6
7
8
# File 'lib/asker/data/world.rb', line 6

def concepts
  @concepts
end

#contextsObject (readonly)

Returns the value of attribute contexts.



6
7
8
# File 'lib/asker/data/world.rb', line 6

def contexts
  @contexts
end

#filenamesObject (readonly)

Returns the value of attribute filenames.



6
7
8
# File 'lib/asker/data/world.rb', line 6

def filenames
  @filenames
end

#image_urlsObject (readonly)

Returns the value of attribute image_urls.



6
7
8
# File 'lib/asker/data/world.rb', line 6

def image_urls
  @image_urls
end

Instance Method Details

#find_neighbors_for_every_concept(concepts) ⇒ Object

For every concept… find its neighbors

Parameters:

  • concepts (Array)


17
18
19
20
21
22
23
24
25
26
# File 'lib/asker/data/world.rb', line 17

def find_neighbors_for_every_concept(concepts)
  concepts.each do |i|
    concepts.each do |j|
      if i.id != j.id
        i.try_adding_neighbor(j)
        i.try_adding_references(j)
      end
    end
  end
end