Module: Imagga::Parametizer
- Included in:
- BaseOptions, ImageOrUrlParametizer, RankColorParametizer, ResolutionParametizer
- Defined in:
- lib/imagga/parametizer.rb
Instance Method Summary collapse
- #build_boolean_options(options, keys) ⇒ Object
- #build_comma_separated_string(objects, field, default_to = nil) ⇒ Object
Instance Method Details
#build_boolean_options(options, keys) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/imagga/parametizer.rb', line 9 def (, keys) [keys].flatten.inject({}) do |result, key| if .keys.include?(key) && (value = [true, '1', 1].include?([key]) ? 1 : 0) result[key] = value end result end end |
#build_comma_separated_string(objects, field, default_to = nil) ⇒ Object
3 4 5 6 7 |
# File 'lib/imagga/parametizer.rb', line 3 def build_comma_separated_string(objects, field, default_to=nil) field_values = [objects].flatten.map{ |o| o.send(field) rescue default_to } return if field_values.uniq == [default_to] field_values.join(',') end |