Class: Yarrow::Web::URL

Inherits:
Object
  • Object
show all
Defined in:
lib/yarrow/web/url.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ URL

Returns a new instance of URL.



20
21
22
# File 'lib/yarrow/web/url.rb', line 20

def initialize(path)
  @path = path
end

Class Method Details

.generate(resource) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/yarrow/web/url.rb', line 7

def self.generate(resource)
  path = if resource.respond_to?(:url)
    resource.url
  elsif resource.respond_to?(:permalink)
    resource.permalink
  else
    # TODO: URL generation strategy
    "/one/two/three"
  end

  new(path)
end

Instance Method Details

#to_sObject



24
25
26
# File 'lib/yarrow/web/url.rb', line 24

def to_s
  @path
end