Class: Dramavladimir::Repertoire

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Repertoire

Returns a new instance of Repertoire.



8
9
10
11
# File 'lib/dramavladimir/repertoire.rb', line 8

def initialize(attributes = {})
  @url = "http://www.dramavladimir.ru/playbill"
  doc
end

Instance Attribute Details

#announceObject

Returns the value of attribute announce.



6
7
8
# File 'lib/dramavladimir/repertoire.rb', line 6

def announce
  @announce
end

#announce_content=(value) ⇒ Object

Sets the attribute announce_content

Parameters:

  • value

    the value to set the attribute announce_content to.



6
7
8
# File 'lib/dramavladimir/repertoire.rb', line 6

def announce_content=(value)
  @announce_content = value
end

#doc=(value) ⇒ Object

Sets the attribute doc

Parameters:

  • value

    the value to set the attribute doc to.



6
7
8
# File 'lib/dramavladimir/repertoire.rb', line 6

def doc=(value)
  @doc = value
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/dramavladimir/repertoire.rb', line 6

def url
  @url
end

Instance Method Details



33
34
35
# File 'lib/dramavladimir/repertoire.rb', line 33

def get_afisha_links
  doc.search('#main-mid table.blog a.contentpagetitle').map { |e| e.attribute('href').value }
end

#spectaclesObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dramavladimir/repertoire.rb', line 13

def spectacles
  spectacles = []
  get_afisha_links.each do |link|
    announces = Dramavladimir.parse("http://www.dramavladimir.ru/#{link}")
    announces.search('.mceItemTable tr').each do |announce|
      @announce = announce
      next unless prepare_date
      spectacles.push({
        title: prepare_title,
        scene: prepare_scene,
        content: prepare_content,
        video: prepare_video,
        images: prepare_images,
        schedules: prepare_date
      })
    end
  end
  spectacles
end