Class: VocabularyToCsv

Inherits:
Object
  • Object
show all
Defined in:
lib/vocabulary_to_csv.rb,
lib/vocabulary_to_csv/version.rb

Overview

Interface to interact with vocabulary.com

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ VocabularyToCsv

Returns a new instance of VocabularyToCsv.



11
12
13
14
# File 'lib/vocabulary_to_csv.rb', line 11

def initialize(id)
  @id = id
  @url = "https://www.vocabulary.com/lists/#{id}"
end

Instance Method Details

#parse_and_save_to_csv(examples: true) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/vocabulary_to_csv.rb', line 16

def parse_and_save_to_csv(examples: true)
  words = scrape_words
  definitions = scrape_definitions
  examples_data = examples ? scrape_examples : Array.new(words.size, "")

  write_to_csv(words, definitions, examples_data)
end