class OxfordLearnersDictionaries::Definition

Attributes

examples[R]
text[R]

Public Class Methods

new(page) click to toggle source
# File lib/oxford_learners_dictionaries/definition.rb, line 7
def initialize page
  @page = page
  @examples = Array.new
end

Public Instance Methods

parse_multiple_definitions(index) click to toggle source
# File lib/oxford_learners_dictionaries/definition.rb, line 19
def parse_multiple_definitions index
  @text = @page.css('.def')[index].text
  return self if @page.css('.x-gs')[index].nil?

  @page.css('.x-gs')[index].css('.x-g').each do |example|
    @examples.push(::OxfordLearnersDictionaries::Example.new(example))
  end
  self
end
parse_single_definition() click to toggle source
# File lib/oxford_learners_dictionaries/definition.rb, line 12
def parse_single_definition
  text =  @page.css('.def')
  @text = text.count > 0 ? text[0].text : text.text
  @examples.push(::OxfordLearnersDictionaries::Example.new(@page.css('.x-g')))
  self
end