Class: CityWatch::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/city_watch/page.rb

Instance Method Summary collapse

Constructor Details

#initializePage

Returns a new instance of Page.



4
5
6
7
# File 'lib/city_watch/page.rb', line 4

def initialize
  html = RestClient.get("#{CityWatch.url}/project.html?projectId=#{CityWatch.project_id}")
  @doc = Nokogiri::HTML(html)
end

Instance Method Details

#build_idObject

Todo: this is gross.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/city_watch/page.rb', line 10

def build_id
  @doc.xpath("//a[contains(.,'#{CityWatch.build_title}')]").
    first.
    parent.
    parent.
    next_sibling.
    next_sibling.
    children.
    first.
    children[2].
    children[1].
    attributes['id'].
    value.
    split(':')[1].
    split(':')[0].
    to_i
end