Class: Rockstar::Venue

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

connection, fetch_and_parse, get_instance

Constructor Details

#initialize(id, name) ⇒ Venue

Returns a new instance of Venue.

Raises:

  • (ArgumentError)


37
38
39
40
41
42
# File 'lib/rockstar/venue.rb', line 37

def initialize(id, name)
  raise ArgumentError, "ID is required" if id.blank?
  raise ArgumentError, "Name is required" if name.blank?
  @vid  = id
  @name = name
end

Instance Attribute Details

#cityObject

Returns the value of attribute city.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def city
  @city
end

#countryObject

Returns the value of attribute country.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def country
  @country
end

#eventsObject

Returns the value of attribute events.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def events
  @events
end

#imagesObject

Returns the value of attribute images.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def images
  @images
end

#latObject

Returns the value of attribute lat.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def lat
  @lat
end

#longObject

Returns the value of attribute long.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def long
  @long
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def name
  @name
end

#phonenumberObject

Returns the value of attribute phonenumber.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def phonenumber
  @phonenumber
end

#postalcodeObject

Returns the value of attribute postalcode.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def postalcode
  @postalcode
end

#streetObject

Returns the value of attribute street.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def street
  @street
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def url
  @url
end

#vidObject

Returns the value of attribute vid.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def vid
  @vid
end

#websiteObject

Returns the value of attribute website.



4
5
6
# File 'lib/rockstar/venue.rb', line 4

def website
  @website
end

Class Method Details

.find(name, country = nil, limit = nil, page = nil) ⇒ Object



32
33
34
# File 'lib/rockstar/venue.rb', line 32

def find(name, country = nil, limit = nil, page = nil)
  get_instance("venue.search", :venues, :venue, {:venue => name, :country => country, :limit => limit, :page => page})
end

.new_from_xml(xml, doc) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rockstar/venue.rb', line 8

def new_from_xml(xml, doc)
  v = Venue.new(
    (xml).at(:id).inner_html,
    (xml).at(:name).inner_html
  )

  v.city       = xml.search("/location/city").inner_html.strip
  v.country    = xml.search("/location/country").inner_html.strip
  v.street     = xml.search("/location/street").inner_html.strip
  v.postalcode = xml.search("/location/postalcode").inner_html.strip
  v.lat        = xml.search("geo:lat").inner_html.strip
  v.long       = xml.search("geo:long").inner_html.strip
  v.url        = xml.search("/url").inner_html.strip
  v.website    = xml.search("/website").inner_html.strip
  v.phonenumber= xml.search("/phonenumber").inner_html.strip

  v.images = {}
  xml.search('/image').each {|image|
    v.images[image['size']] = image.inner_html if v.images[image['size']].nil?
  }

  v
end

Instance Method Details

#image(which = :medium) ⇒ Object

Raises:

  • (ArgumentError)


44
45
46
47
48
49
50
51
# File 'lib/rockstar/venue.rb', line 44

def image(which=:medium)
  which = which.to_s
  raise ArgumentError unless ['small', 'medium', 'large', 'extralarge', 'mega'].include?(which)
  if (self.images.nil?)
    load_info
  end
  self.images[which]
end