Class: LaundryView::Sync

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/laundryview/main.rb

Constant Summary collapse

WINDSOR =
185842

Instance Method Summary collapse

Constructor Details

#initialize(room) ⇒ Sync



9
10
11
12
13
14
15
16
17
# File 'lib/laundryview/main.rb', line 9

def initialize room
  @room = room
  @agent = Curl::Easy.new "http://laundryview.com/laundry_room.php?lr=#{@room}"
  @agent.follow_location = true
  @agent.enable_cookies = true
  @agent.perform
  self.update
  nil
end

Instance Method Details

#countObject



25
26
27
# File 'lib/laundryview/main.rb', line 25

def count
  @machines.count
end

#each(&block) ⇒ Object



29
30
31
# File 'lib/laundryview/main.rb', line 29

def each &block
  @machines.each &block
end

#updateObject



19
20
21
22
23
# File 'lib/laundryview/main.rb', line 19

def update
  @agent.url = "http://laundryview.com/classic_laundry_room_ajax.php?lr=#{@room}"
  @agent.perform
  @machines = parse_body @agent.body_str
end