Class: Camdict::Explanation

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/camdict/explanation.rb

Overview

Explanation are inside the def-block node.

Defined Under Namespace

Classes: Sentence

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ Explanation

Parse html to get level, meaning, example sentences, synonym, opposite, usage, grammar code, region, variant.



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/camdict/explanation.rb', line 40

def initialize(html)
  @html = html
  @level = get_level                      # String
  @variant = get_variant                  # String
  @meaning = get_meaning                  # String
  @gc = css_text(".gcs")                  # String
  @usage = css_text(".usage")             # String
  @region = css_text(".region")           # String
  @examples = get_examples                # [Sentence]
  @synonym = get_synonym                  # String
  @opposite = get_opposite                # String
  # todo: add usage panel - the word: somewhere.
end

Instance Attribute Details

#examplesObject (readonly)

Get example sentences



15
16
17
# File 'lib/camdict/explanation.rb', line 15

def examples
  @examples
end

#gcObject (readonly)

Grammar code. Full list is dictionary.cambridge.org/help/codes.html



36
37
38
# File 'lib/camdict/explanation.rb', line 36

def gc
  @gc
end

#levelObject (readonly)

Elementary level. It’s a symbol indicating the level when learnders know this meaning.

A1: Beginner,       A2: Elementary, 
B1: Intermediate,   B2: Upper-Intermediate,
C1: Advanced,       C2: Proficiency


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

def level
  @level
end

#meaningObject (readonly)

A meaning of the word



24
25
26
# File 'lib/camdict/explanation.rb', line 24

def meaning
  @meaning
end

#oppositeObject (readonly)

Get opposite word



21
22
23
# File 'lib/camdict/explanation.rb', line 21

def opposite
  @opposite
end

#regionObject (readonly)

The meaning is used in which region - UK or US.



30
31
32
# File 'lib/camdict/explanation.rb', line 30

def region
  @region
end

#synonymObject (readonly)

Get synonym word



18
19
20
# File 'lib/camdict/explanation.rb', line 18

def synonym
  @synonym
end

#usageObject (readonly)

One or two words usage note. For example, slang.



27
28
29
# File 'lib/camdict/explanation.rb', line 27

def usage
  @usage
end

#variantObject (readonly)

For a specific explanation, the word may have a variant form.



33
34
35
# File 'lib/camdict/explanation.rb', line 33

def variant
  @variant
end