Class: Honey::DataFeed
- Inherits:
-
Object
- Object
- Honey::DataFeed
- Defined in:
- lib/honey/data_feed.rb
Overview
Data Feed
Access Honey’s Place data feeds in various formats
Constant Summary collapse
- Formats =
%i(xml json csv woo shopify amazon_inventory).freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Instance Method Summary collapse
- #download_to(path) ⇒ Object
-
#initialize(code, format) ⇒ DataFeed
constructor
A new instance of DataFeed.
- #parse ⇒ Object
- #url ⇒ Object
Constructor Details
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/honey/data_feed.rb', line 8 def code @code end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
8 9 10 |
# File 'lib/honey/data_feed.rb', line 8 def format @format end |
Instance Method Details
#download_to(path) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/honey/data_feed.rb', line 28 def download_to(path) File.open(path, 'w') do |file| file.write(read) # HTTParty.get(url, stream: true) do |fragment| # file.write(fragment) # end end end |
#parse ⇒ Object
24 25 26 |
# File 'lib/honey/data_feed.rb', line 24 def parse read end |
#url ⇒ Object
17 18 19 20 21 22 |
# File 'lib/honey/data_feed.rb', line 17 def url if format.nil? raise ArgumentError, "format is required to be one of #{Formats}" end "https://www.honeysplace.com/df/#{code}/#{format}" end |