Class: Camdict::Explanation

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

Overview

Explanation are inside the def-block node.

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.



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

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

Instance Attribute Details

#codeObject (readonly)

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



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

def code
  @code
end

#examplesObject (readonly)

Get example sentences



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

def examples
  @examples
end

#levelObject (readonly)

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

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


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

def level
  @level
end

#meaningObject (readonly)

A meaning of the word



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

def meaning
  @meaning
end

#oppositeObject (readonly)

Get opposite word



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

def opposite
  @opposite
end

#regionObject (readonly)

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



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

def region
  @region
end

#synonymObject (readonly)

Get synonym word



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

def synonym
  @synonym
end

#usageObject (readonly)

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



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

def usage
  @usage
end

#variantObject (readonly)

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



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

def variant
  @variant
end