Class: RailsDominantColors::Url
- Defined in:
- lib/rails_dominant_colors/url.rb
Constant Summary
Constants inherited from Base
Base::EmptySource, Base::FileNotFound, Base::InvalidBase64, Base::InvalidUrl, Base::NotAnImage, Base::UrlNotFound
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(source, colors) ⇒ Url
constructor
A new instance of Url.
- #process(source) ⇒ Object
Methods inherited from Base
#to_hex, #to_hex_alpha, #to_hsl, #to_hsl_alpha, #to_pct, #to_rgb, #to_rgb_alpha
Constructor Details
#initialize(source, colors) ⇒ Url
Returns a new instance of Url.
7 8 9 10 11 |
# File 'lib/rails_dominant_colors/url.rb', line 7 def initialize(source, colors) raise(EmptySource) if source.nil? || source.empty? super(process(source), colors) end |
Instance Method Details
#process(source) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rails_dominant_colors/url.rb', line 13 def process(source) raise(InvalidUrl) unless valid_url?(source) ri = remote_image(source) content_type = ri.content_type.to_sym extension = extensions[content_type] raise(NotAnImage) if extension.nil? tempfile(extension, ri.body) end |