Class: FormattedURL::Strategies::DefaultURLStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/formatted_url/strategies/default_url_strategy.rb

Overview

Default strategy to manage paths. Returns the path by default

Direct Known Subclasses

YoutubeURLStrategy

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ DefaultURLStrategy

Receives URL path



18
19
20
# File 'lib/formatted_url/strategies/default_url_strategy.rb', line 18

def initialize(path)
  @path = path
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object

Returns default path when receive unknown message



29
30
31
# File 'lib/formatted_url/strategies/default_url_strategy.rb', line 29

def method_missing(*args)
  default
end

Instance Attribute Details

#pathObject (readonly)

The URL path



10
11
12
# File 'lib/formatted_url/strategies/default_url_strategy.rb', line 10

def path
  @path
end

Class Method Details

.url(path, format) ⇒ Object

Formats path for a given format



13
14
15
# File 'lib/formatted_url/strategies/default_url_strategy.rb', line 13

def self.url(path, format)
  new(path).send(format)
end

Instance Method Details

#defaultObject

Returns path by default



23
24
25
# File 'lib/formatted_url/strategies/default_url_strategy.rb', line 23

def default
  path
end