Class: HTTPThumbnailerClient::URIBuilder
- Inherits:
-
Object
- Object
- HTTPThumbnailerClient::URIBuilder
- Defined in:
- lib/httpthumbnailer-client/uri_builder.rb
Instance Attribute Summary collapse
-
#specs ⇒ Object
readonly
Returns the value of attribute specs.
Class Method Summary collapse
- .specs(*specs) ⇒ Object
- .thumbnail(method, width, height, format = 'jpeg', options = {}, &block) ⇒ Object
- .thumbnails(&block) ⇒ Object
Instance Method Summary collapse
-
#initialize(&block) ⇒ URIBuilder
constructor
A new instance of URIBuilder.
- #thumbnail(method, width, height, format = 'jpeg', options = {}, &block) ⇒ Object
- #thumbnail_spec(spec) ⇒ Object
- #to_s ⇒ Object (also: #get)
Constructor Details
#initialize(&block) ⇒ URIBuilder
Returns a new instance of URIBuilder.
5 6 7 8 |
# File 'lib/httpthumbnailer-client/uri_builder.rb', line 5 def initialize(&block) @specs = [] instance_eval(&block) if block end |
Instance Attribute Details
#specs ⇒ Object (readonly)
Returns the value of attribute specs.
33 34 35 |
# File 'lib/httpthumbnailer-client/uri_builder.rb', line 33 def specs @specs end |
Class Method Details
.specs(*specs) ⇒ Object
18 19 20 21 22 |
# File 'lib/httpthumbnailer-client/uri_builder.rb', line 18 def self.specs(*specs) specs.each.with_object(new) do |spec, builder| builder.thumbnail_spec spec end.to_s end |
.thumbnail(method, width, height, format = 'jpeg', options = {}, &block) ⇒ Object
10 11 12 |
# File 'lib/httpthumbnailer-client/uri_builder.rb', line 10 def self.thumbnail(method, width, height, format = 'jpeg', = {}, &block) self.new.thumbnail(method, width, height, format, , &block).to_s end |
.thumbnails(&block) ⇒ Object
14 15 16 |
# File 'lib/httpthumbnailer-client/uri_builder.rb', line 14 def self.thumbnails(&block) self.new(&block).to_s end |
Instance Method Details
#thumbnail(method, width, height, format = 'jpeg', options = {}, &block) ⇒ Object
24 25 26 27 |
# File 'lib/httpthumbnailer-client/uri_builder.rb', line 24 def thumbnail(method, width, height, format = 'jpeg', = {}, &block) thumbnail_spec ThumbnailSpec::Builder.new(method, width.to_s, height.to_s, format, , &block).spec self end |
#thumbnail_spec(spec) ⇒ Object
29 30 31 |
# File 'lib/httpthumbnailer-client/uri_builder.rb', line 29 def thumbnail_spec(spec) @specs << spec end |
#to_s ⇒ Object Also known as: get
35 36 37 38 |
# File 'lib/httpthumbnailer-client/uri_builder.rb', line 35 def to_s uri = @specs.length > 1 ? '/thumbnails' : '/thumbnail' "#{uri}/#{@specs.map(&:to_s).join('/')}" end |