Class: Webstract::Favicon
- Inherits:
-
Object
- Object
- Webstract::Favicon
- Defined in:
- lib/webstract/favicon.rb
Instance Attribute Summary collapse
-
#favicon_data ⇒ Object
Returns the value of attribute favicon_data.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #fetch ⇒ Object
- #fetch_and_save(path) ⇒ Object
-
#initialize(options = {}) ⇒ Favicon
constructor
A new instance of Favicon.
Constructor Details
#initialize(options = {}) ⇒ Favicon
Returns a new instance of Favicon.
7 8 9 10 |
# File 'lib/webstract/favicon.rb', line 7 def initialize( = {}) raise(ArgumentError.new("requires url")) unless .key?(:url) @url = [:url] end |
Instance Attribute Details
#favicon_data ⇒ Object
Returns the value of attribute favicon_data.
5 6 7 |
# File 'lib/webstract/favicon.rb', line 5 def favicon_data @favicon_data end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/webstract/favicon.rb', line 5 def url @url end |
Instance Method Details
#fetch ⇒ Object
12 13 14 |
# File 'lib/webstract/favicon.rb', line 12 def fetch @favicon_data = Faviconduit.get(url).data end |
#fetch_and_save(path) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/webstract/favicon.rb', line 16 def fetch_and_save(path) data = fetch File.open(path, 'w') do |f| f.write(data) f.close end end |