Class: Imgix::Style

Inherits:
Object
  • Object
show all
Defined in:
lib/imgix/style.rb

Constant Summary collapse

VALID_PARAMS =
[:auto, :bg, :blend, :blendalign, :blendalpha,
:blendcrop, :blendfit, :blendheight, :blendmode, :blendpadding,
:blendsize, :blendwidth, :blur, :border, :bri, :colors, :con,
:crop, :dl, :dpr, :exp, :fit, :flip, :fm, :gam, :h, :high, :htn,
:hue, :invert, :mark, :markalign, :markfit, :markh, :markpad,
:markscale, :markw, :mask, :mono, :nr, :nrs, :or, :page, :palette,
:prefix, :px, :q, :rect, :rot, :sat, :sepia, :shad, :sharp, :txt,
:txtalign, :txtclip, :txtclr, :txtfit, :txtfont, :txtline, :txtlineclr,
:txtpad, :txtshad, :txtsize, :txtwidth, :vib, :w]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attachment, options = {}) ⇒ Style

Returns a new instance of Style.



15
16
17
18
19
20
21
22
# File 'lib/imgix/style.rb', line 15

def initialize(name, attachment, options = {})
  @name       = name
  @attachment = attachment
  @options    = options
  if @options.is_a?(Hash)
    @options = @options.delete_if {|k, v| !Imgix::Style.is_param_valid?(k) }
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/imgix/style.rb', line 3

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/imgix/style.rb', line 3

def options
  @options
end

Class Method Details

.is_param_valid?(param) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/imgix/style.rb', line 28

def self.is_param_valid?(param)
  VALID_PARAMS.include?(param.to_sym)
end

Instance Method Details

#to_sObject



24
25
26
# File 'lib/imgix/style.rb', line 24

def to_s
  self.options.to_param
end