Class: Upcoming::Venue

Inherits:
Object
  • Object
show all
Defined in:
lib/upcoming/venue.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, city, url, user_id, visibility, lat, lng, gc_precision) ⇒ Venue

Returns a new instance of Venue.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/upcoming/venue.rb', line 9

def initialize(id, name, city, url, user_id, visibility, lat, lng, gc_precision)
  @id = id
  @name = name
  @city = city
  @url = url
  @user_id = user_id
  @visibility = visibility
  @lat = lat
  @lng = lng
  @gc_precision = gc_precision
end

Instance Attribute Details

#cityObject (readonly)

Returns the value of attribute city.



7
8
9
# File 'lib/upcoming/venue.rb', line 7

def city
  @city
end

#gc_precisionObject (readonly)

Returns the value of attribute gc_precision.



7
8
9
# File 'lib/upcoming/venue.rb', line 7

def gc_precision
  @gc_precision
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/upcoming/venue.rb', line 7

def id
  @id
end

#latObject (readonly)

Returns the value of attribute lat.



7
8
9
# File 'lib/upcoming/venue.rb', line 7

def lat
  @lat
end

#lngObject (readonly)

Returns the value of attribute lng.



7
8
9
# File 'lib/upcoming/venue.rb', line 7

def lng
  @lng
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/upcoming/venue.rb', line 7

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/upcoming/venue.rb', line 7

def url
  @url
end

#user_idObject (readonly)

Returns the value of attribute user_id.



7
8
9
# File 'lib/upcoming/venue.rb', line 7

def user_id
  @user_id
end

Class Method Details

.info(venue_id, token = nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/upcoming/venue.rb', line 31

def self.info(venue_id, token=nil)
  params = {:method => 'venue.getInfo', :venue_id => venue_id}
  params[:token] = token unless token.nil?
  
  req = Upcoming::Request.new
  resp = req.send(params)
  
  doc = Document.new(resp.body)
  el = XPath.first(doc, '//venue')
  
  Venue.new(
    el.attribute('id').value,
    el.attribute('name').value,
    el.attribute('city').value,
    el.attribute('url').value,
    el.attribute('user_id').value,
    el.attribute('private').value,
    el.attribute('latitude').value,
    el.attribute('longitude').value,
    el.attribute('geocoding_precision').value
  )
end

.list(metro_id, token = nil) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/upcoming/venue.rb', line 54

def self.list(metro_id, token=nil)
  params = {:method => 'venue.getList', :metro_id => metro_id}
  params[:token] = token unless token.nil?
  
  req = Upcoming::Request.new
  resp = req.send(params)
  
  venues = []
  
  doc = Document.new(resp.body)
  XPath.each(doc, '//venue') do |v|
    # TODO parse my elements, yo!
  end
  
  venues
end

.search(params) ⇒ Object



27
28
29
# File 'lib/upcoming/venue.rb', line 27

def self.search(params)
  # TODO implement venue search
end

Instance Method Details

#private?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
# File 'lib/upcoming/venue.rb', line 21

def private?
  return false if @visibility.nil? || @visibility == 0
  
  return true
end