Class: Define::Word_lookup

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

Instance Method Summary collapse

Constructor Details

#initialize(word) ⇒ Word_lookup

Returns a new instance of Word_lookup.



7
8
9
10
# File 'lib/define.rb', line 7

def initialize (word)
  @word     = word
  @full_def = look_up
end

Instance Method Details

#definitionObject



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

def definition
  @full_def
end

#typeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/define.rb', line 16

def type
  matchdata = @full_def.match /^\s+(?<word>#{@word})\s+(?<type>\w+)\s+\d:/
  type = matchdata[:type]
  case type
    when "n" then
      :noun
    when "adv" then
      :adverb
    when "adj" then
      :adjective
    when "v" then
      :verb
  end
end