Class: RScale::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/rscale/format.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Format

Returns a new instance of Format.



6
7
8
9
10
# File 'lib/rscale/format.rb', line 6

def initialize(name)
  @name = name.to_s
  @styles = {}
  @url = '/:format/:style/:uuid_dir/:uuid.:extension'
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rscale/format.rb', line 3

def name
  @name
end

#stylesObject

Returns the value of attribute styles.



4
5
6
# File 'lib/rscale/format.rb', line 4

def styles
  @styles
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/rscale/format.rb', line 4

def url
  @url
end

Instance Method Details

#style(name, opts = {}) ⇒ Object

Add a new style

Raises:



13
14
15
16
17
18
# File 'lib/rscale/format.rb', line 13

def style(name, opts={})
  raise FormatError, 'Options required!' if opts.empty?
  raise FormatError, 'Options must be a Hash!' unless opts.kind_of?(Hash)
  opts[:style] = name
  @styles[name] = opts
end