Class: Snapshot::URL

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, extension, &block) ⇒ URL

Returns a new instance of URL.



5
6
7
8
9
10
# File 'lib/snapshot/url.rb', line 5

def initialize(id, extension, &block)
  @id = id
  @extension = extension
  @options = []
  tap(&block) if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(processor, *options) ⇒ Object



12
13
14
# File 'lib/snapshot/url.rb', line 12

def method_missing(processor, *options)
  @options << [":#{processor}", options]
end

Instance Attribute Details

#extensionObject (readonly)

Returns the value of attribute extension.



3
4
5
# File 'lib/snapshot/url.rb', line 3

def extension
  @extension
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/snapshot/url.rb', line 3

def id
  @id
end

Instance Method Details

#to_sObject



16
17
18
19
20
# File 'lib/snapshot/url.rb', line 16

def to_s
  options = @options.flatten
  options << '' unless options.empty?
  "#{Snapshot.connection.url}#{options.join('/')}#{id}.#{extension}"
end