Class: RandomWordByLength::Word

Inherits:
Object
  • Object
show all
Defined in:
lib/random_word_by_length/word.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spelling) ⇒ Word

Returns a new instance of Word.



5
6
7
# File 'lib/random_word_by_length/word.rb', line 5

def initialize(spelling)
  @spelling = spelling
end

Instance Attribute Details

#definitionObject

Returns the value of attribute definition.



3
4
5
# File 'lib/random_word_by_length/word.rb', line 3

def definition
  @definition
end

#kindObject

Returns the value of attribute kind.



3
4
5
# File 'lib/random_word_by_length/word.rb', line 3

def kind
  @kind
end

#spellingObject

Returns the value of attribute spelling.



3
4
5
# File 'lib/random_word_by_length/word.rb', line 3

def spelling
  @spelling
end

#synonymsObject

Returns the value of attribute synonyms.



3
4
5
# File 'lib/random_word_by_length/word.rb', line 3

def synonyms
  @synonyms
end

Class Method Details

.easyObject



9
10
11
12
13
14
15
16
17
# File 'lib/random_word_by_length/word.rb', line 9

def self.easy
  word = RandomWordByLength::Scraper.get_easy_word
  attributes = RandomWordByLength::Scraper.get_word_attributes(word)
  word = self.new(word)
  word.definition = attributes[0]
  word.kind = attributes[1]
  word.synonyms = "https://www.thesaurus.com/browse/#{word.spelling}"
  word
end

.hardObject



29
30
31
32
33
34
35
36
37
# File 'lib/random_word_by_length/word.rb', line 29

def self.hard
  word = RandomWordByLength::Scraper.get_hard_word
  attributes = RandomWordByLength::Scraper.get_word_attributes(word)
  word = self.new(word)
  word.definition = attributes[0]
  word.kind = attributes[1]
  word.synonyms = "https://www.thesaurus.com/browse/#{word.spelling}"
  word
end

.mediumObject



19
20
21
22
23
24
25
26
27
# File 'lib/random_word_by_length/word.rb', line 19

def self.medium
  word = RandomWordByLength::Scraper.get_medium_word
  attributes = RandomWordByLength::Scraper.get_word_attributes(word)
  word = self.new(word)
  word.definition = attributes[0]
  word.kind = attributes[1]
  word.synonyms = "https://www.thesaurus.com/browse/#{word.spelling}"
  word
end