Class: Datasets::PenguinsRawData::SpeciesBase
- Defined in:
- lib/datasets/penguins.rb
Instance Attribute Summary collapse
-
#data_path ⇒ Object
readonly
Returns the value of attribute data_path.
Attributes inherited from Dataset
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize ⇒ SpeciesBase
constructor
A new instance of SpeciesBase.
Methods inherited from Dataset
Constructor Details
#initialize ⇒ SpeciesBase
Returns a new instance of SpeciesBase.
24 25 26 27 28 29 30 31 |
# File 'lib/datasets/penguins.rb', line 24 def initialize super species = self.class.name.split("::").last.downcase .id = "palmerpenguins-raw-#{species}" .url = self.class::URL .licenses = ["CC0"] @data_path = cache_dir_path + "penguins" + (species + ".csv") end |
Instance Attribute Details
#data_path ⇒ Object (readonly)
Returns the value of attribute data_path.
33 34 35 |
# File 'lib/datasets/penguins.rb', line 33 def data_path @data_path end |
Instance Method Details
#each ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/datasets/penguins.rb', line 35 def each return to_enum(__method__) unless block_given? open_data do |csv| csv.each do |row| next if row[0].nil? record = Record.new(*row.fields) yield record end end end |