Class: GsImgFetcher::Entry
- Inherits:
-
Object
- Object
- GsImgFetcher::Entry
- Defined in:
- lib/gs_img_fetcher/entry.rb
Constant Summary collapse
- ALLOWED_EXTENSIONS =
%w[jpeg jpg png gif svg].freeze
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #extension ⇒ Object
-
#initialize(url) ⇒ Entry
constructor
A new instance of Entry.
- #valid? ⇒ Boolean
Constructor Details
#initialize(url) ⇒ Entry
Returns a new instance of Entry.
9 10 11 |
# File 'lib/gs_img_fetcher/entry.rb', line 9 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/gs_img_fetcher/entry.rb', line 7 def url @url end |
Instance Method Details
#extension ⇒ Object
13 14 15 |
# File 'lib/gs_img_fetcher/entry.rb', line 13 def extension @extension ||= ([filename.split('.').last&.downcase] & ALLOWED_EXTENSIONS).first end |
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/gs_img_fetcher/entry.rb', line 17 def valid? [filename, extension].all?(&:present?) end |