Class: Datasets::Seaborn
Constant Summary collapse
- URL_FORMAT =
"https://raw.githubusercontent.com/mwaskom/seaborn-data/master/%{name}.csv".freeze
Instance Attribute Summary
Attributes inherited from Dataset
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(name) ⇒ Seaborn
constructor
A new instance of Seaborn.
Methods inherited from Dataset
Constructor Details
#initialize(name) ⇒ Seaborn
Returns a new instance of Seaborn.
36 37 38 39 40 41 42 43 44 |
# File 'lib/datasets/seaborn.rb', line 36 def initialize(name) super() @metadata.id = "seaborn-#{name}" @metadata.name = "seaborn: #{name}" @metadata.url = URL_FORMAT % {name: name} # @metadata.licenses = TODO @name = name end |
Instance Method Details
#each(&block) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/datasets/seaborn.rb', line 46 def each(&block) return to_enum(__method__) unless block_given? data_path = cache_dir_path + "#{@name}.csv" download(data_path, @metadata.url) CSV.open(data_path, headers: :first_row, converters: :all) do |csv| csv.each do |row| record = prepare_record(row) yield record end end end |