Class: Hootenanny::Topic

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Topic

Returns a new instance of Topic.



8
9
10
# File 'lib/hootenanny/topic.rb', line 8

def initialize(options = {})
  self.url = Hootenanny::URI.parse(options.fetch(:url))
end

Instance Attribute Details

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/hootenanny/topic.rb', line 6

def url
  @url
end

Class Method Details

.from_url(url, options = {}) ⇒ Object

Private: Creates a topic from a String representing the URL of the topic

url - A String representing the URL of the topic

Examples:

Hootenanny::Topic.from_url('http://example.com')

Returns a Hootenanny::Topic Raises a Hootenanny::URI::InvalidError if the URI cannot be parsed Raises a Hootenanny::URI::InvalidSchemeError if the URI is not either HTTP

or HTTPS


26
27
28
29
30
31
32
# File 'lib/hootenanny/topic.rb', line 26

def self.from_url(url, options = {})
  topic = allocate

  topic.send(:initialize, options.merge(:url => url))

  topic
end