Class: Zurl

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

Instance Method Summary collapse

Constructor Details

#initialize(base_url) ⇒ Zurl

Returns a new instance of Zurl.



2
3
4
5
# File 'lib/ttc_feed/zurl.rb', line 2

def initialize(base_url)
  @url_so_far = base_url
  @first_param_already_used = false
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/ttc_feed/zurl.rb', line 7

def method_missing(meth, *args)
  param_prefix = @first_param_already_used ? "&" : "?"

  @url_so_far << param_prefix << meth.to_s
  @url_so_far << "=" << args.first unless args.first.nil?

  @first_param_already_used = true
  self
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/ttc_feed/zurl.rb', line 17

def to_s
  @url_so_far
end