Class: Camdict::Explanation
- Inherits:
-
Object
- Object
- Camdict::Explanation
- Includes:
- Common
- Defined in:
- lib/camdict/explanation.rb
Overview
Explanation are inside the def-block node.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Grammar code.
-
#examples ⇒ Object
readonly
Get example sentences.
-
#level ⇒ Object
readonly
Elementary level.
-
#meaning ⇒ Object
readonly
A meaning of the word.
-
#opposite ⇒ Object
readonly
Get opposite word.
-
#region ⇒ Object
readonly
The meaning is used in which region - UK or US.
-
#synonym ⇒ Object
readonly
Get synonym word.
-
#usage ⇒ Object
readonly
One or two words usage note.
-
#variant ⇒ Object
readonly
For a specific explanation, the word may have a variant form.
Instance Method Summary collapse
-
#initialize(html) ⇒ Explanation
constructor
Parse
html
to get level, meaning, example sentences, synonym, opposite, usage, grammar code, region, variant.
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
#code ⇒ Object (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 |
#examples ⇒ Object (readonly)
Get example sentences
16 17 18 |
# File 'lib/camdict/explanation.rb', line 16 def examples @examples end |
#level ⇒ Object (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 |
#meaning ⇒ Object (readonly)
A meaning of the word
25 26 27 |
# File 'lib/camdict/explanation.rb', line 25 def meaning @meaning end |
#opposite ⇒ Object (readonly)
Get opposite word
22 23 24 |
# File 'lib/camdict/explanation.rb', line 22 def opposite @opposite end |
#region ⇒ Object (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 |
#synonym ⇒ Object (readonly)
Get synonym word
19 20 21 |
# File 'lib/camdict/explanation.rb', line 19 def synonym @synonym end |
#usage ⇒ Object (readonly)
One or two words usage note. For example, slang.
28 29 30 |
# File 'lib/camdict/explanation.rb', line 28 def usage @usage end |
#variant ⇒ Object (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 |