Class: Portal

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Portal

Returns a new instance of Portal.


5
6
7
8
# File 'lib/portal.rb', line 5

def initialize(url)
  @url = url
  @@all << self
end

Instance Attribute Details

#nameObject

Returns the value of attribute name


2
3
4
# File 'lib/portal.rb', line 2

def name
  @name
end

#topicObject

Returns the value of attribute topic


2
3
4
# File 'lib/portal.rb', line 2

def topic
  @topic
end

#urlObject

Returns the value of attribute url


2
3
4
# File 'lib/portal.rb', line 2

def url
  @url
end

Class Method Details

.allObject


10
11
12
# File 'lib/portal.rb', line 10

def self.all
  @@all
end

.find_or_create_by_url(url) ⇒ Object


14
15
16
17
18
19
20
21
# File 'lib/portal.rb', line 14

def self.find_or_create_by_url(url)
  if Portal.all.detect{|portal| url == portal.url}
    @portal = Portal.all.detect{|portal| url == portal.url}
  else
    @portal = Portal.new(url)
    @portal
  end
end