Class: Rockstar::Event
Instance Attribute Summary collapse
-
#artists ⇒ Object
Returns the value of attribute artists.
-
#attendance ⇒ Object
Returns the value of attribute attendance.
-
#cancelled ⇒ Object
Returns the value of attribute cancelled.
-
#description ⇒ Object
Returns the value of attribute description.
-
#eid ⇒ Object
Returns the value of attribute eid.
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#headliners ⇒ Object
Returns the value of attribute headliners.
-
#images ⇒ Object
Returns the value of attribute images.
-
#reviews ⇒ Object
Returns the value of attribute reviews.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#tickets ⇒ Object
Returns the value of attribute tickets.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
-
#venue ⇒ Object
Returns the value of attribute venue.
-
#website ⇒ Object
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
- #image(which = :medium) ⇒ Object
-
#initialize(id, title) ⇒ Event
constructor
A new instance of Event.
Methods inherited from Base
connection, fetch_and_parse, get_instance
Constructor Details
#initialize(id, title) ⇒ Event
Returns a new instance of Event.
56 57 58 59 60 61 |
# File 'lib/rockstar/event.rb', line 56 def initialize(id, title) raise ArgumentError, "ID is required" if id.blank? raise ArgumentError, "Title is required" if title.blank? @eid = id @title = title end |
Instance Attribute Details
#artists ⇒ Object
Returns the value of attribute artists.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def artists @artists end |
#attendance ⇒ Object
Returns the value of attribute attendance.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def attendance @attendance end |
#cancelled ⇒ Object
Returns the value of attribute cancelled.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def cancelled @cancelled end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def description @description end |
#eid ⇒ Object
Returns the value of attribute eid.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def eid @eid end |
#end_date ⇒ Object
Returns the value of attribute end_date.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def end_date @end_date end |
#headliners ⇒ Object
Returns the value of attribute headliners.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def headliners @headliners end |
#images ⇒ Object
Returns the value of attribute images.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def images @images end |
#reviews ⇒ Object
Returns the value of attribute reviews.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def reviews @reviews end |
#start_date ⇒ Object
Returns the value of attribute start_date.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def start_date @start_date end |
#tag ⇒ Object
Returns the value of attribute tag.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def tag @tag end |
#tags ⇒ Object
Returns the value of attribute tags.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def @tags end |
#tickets ⇒ Object
Returns the value of attribute tickets.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def tickets @tickets end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def url @url end |
#venue ⇒ Object
Returns the value of attribute venue.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def venue @venue end |
#website ⇒ Object
Returns the value of attribute website.
4 5 6 |
# File 'lib/rockstar/event.rb', line 4 def website @website end |
Class Method Details
.new_from_xml(xml, doc) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rockstar/event.rb', line 9 def new_from_xml(xml, doc) e = Event.new( (xml).at(:id).inner_html, (xml).at(:title).inner_html ) e.artists = [] xml.search("/artists/artist").each {|a| e.artists << a.inner_html } e.headliners = [] xml.search("/artists/headliner").each{|h| e.headliners << h.inner_html } e.start_date = Base.parse_time(xml.search("/startDate").inner_html.strip) e.end_date = Base.parse_time(xml.search("/endDate").inner_html.strip) e.description = xml.search("/description").inner_html.strip e.attendance = xml.search("/attendance").inner_html.strip.to_i e.reviews = xml.search("/reviews").inner_html.strip.to_i e.tag = xml.search("/tag").inner_html.strip e.url = xml.search("/url").inner_html.strip e.website = xml.search("/website").inner_html.strip e.cancelled = xml.search("/cancelled").inner_html.strip == 1 e.tickets = [] xml.search("/tickets/ticket").each{|t| e.tickets << t.inner_html } e. = [] xml.search("/tags/tag").each{|t| e. << t.inner_html } e.images = {} xml.search('/image').each {|image| e.images[image['size']] = image.inner_html if e.images[image['size']].nil? } e.venue = Venue.new_from_xml(xml.search('/venue'), doc) if xml.search('/venue') e end |
Instance Method Details
#image(which = :medium) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/rockstar/event.rb', line 63 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 |