Class: Upcoming::Event

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs_hash) ⇒ Event

Returns a new instance of Event.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/upcoming/event.rb', line 12

def initialize(attrs_hash)
  @id             = attrs_hash[:id]
  @name           = attrs_hash[:name]
  @description    = attrs_hash[:description]
  @start_date     = attrs_hash[:start_date]
  @end_date       = attrs_hash[:end_date]
  @start_time     = attrs_hash[:start_time]
  @end_time       = attrs_hash[:end_time]
  @date_posted    = attrs_hash[:date_posted]
  @personal       = attrs_hash[:personal]
  @self_promotion = attrs_hash[:self_promotion]
  @lat            = attrs_hash[:lat]
  @lng            = attrs_hash[:lng]
  @gc_precision   = attrs_hash[:gc_precision]
  @gc_ambiguous   = attrs_hash[:gc_ambiguous]
  @user_id        = attrs_hash[:user_id]
  @category_id    = attrs_hash[:category_id]
  @venue_id       = attrs_hash[:venue_id]
  @metro_id       = attrs_hash[:metro_id]
  @state_id       = attrs_hash[:state_id]
  @country_id     = attrs_hash[:country_id]
end

Instance Attribute Details

#date_postedObject (readonly)

Returns the value of attribute date_posted.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def date_posted
  @date_posted
end

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def description
  @description
end

#end_dateObject (readonly)

Returns the value of attribute end_date.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def end_date
  @end_date
end

#end_timeObject (readonly)

Returns the value of attribute end_time.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def end_time
  @end_time
end

#gc_ambiguousObject (readonly)

Returns the value of attribute gc_ambiguous.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def gc_ambiguous
  @gc_ambiguous
end

#gc_precisionObject (readonly)

Returns the value of attribute gc_precision.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def gc_precision
  @gc_precision
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def id
  @id
end

#latObject (readonly)

Returns the value of attribute lat.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def lat
  @lat
end

#lngObject (readonly)

Returns the value of attribute lng.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def lng
  @lng
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def name
  @name
end

#personalObject (readonly)

Returns the value of attribute personal.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def personal
  @personal
end

#self_promotionObject (readonly)

Returns the value of attribute self_promotion.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def self_promotion
  @self_promotion
end

#start_dateObject (readonly)

Returns the value of attribute start_date.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def start_date
  @start_date
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



8
9
10
# File 'lib/upcoming/event.rb', line 8

def start_time
  @start_time
end

Class Method Details

.create_from_node(node) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/upcoming/event.rb', line 88

def self.create_from_node(node)
  attrs = {}
  
  attrs[:id] = node.attribute('id').value
  attrs[:name] = node.attribute('name').value
  attrs[:description] = node.attribute('description').value
  attrs[:start_date] = node.attribute('start_date').value
  attrs[:end_date] = node.attribute('end_date').value
  attrs[:start_time] = node.attribute('start_time').value
  attrs[:end_time] = node.attribute('end_time').value
  attrs[:date_posted] = node.attribute('date_posted').value
  attrs[:personal] = node.attribute('personal').value
  attrs[:self_promotion] = node.attribute('selfpromotion').value
  attrs[:lat] = node.attribute('latitude').value
  attrs[:lng] = node.attribute('longitude').value
  attrs[:gc_precision] = node.attribute('geocoding_precision').value
  attrs[:gc_ambiguous] = node.attribute('geocoding_ambiguous').value
  attrs[:user_id] = node.attribute('user_id').value
  attrs[:category_id] = node.attribute('category_id').value
  attrs[:venue_id] = node.attribute('venue_id').value
  attrs[:metro_id] = node.attribute('metro_id').value
  attrs[:state_id] = node.attribute('venue_state_id').value
  attrs[:country_id] = node.attribute('venue_country_id').value
  
  Event.new(attrs)
end

.get_info(event_id) ⇒ Object



67
68
69
# File 'lib/upcoming/event.rb', line 67

def self.get_info(event_id)
  # TODO get event info by event id
end

.search(params) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/upcoming/event.rb', line 71

def self.search(params)
  params[:method] = 'event.search' if params[:method].nil?
  
  req = Upcoming::Request.new
  resp = req.send(params)
  
  events = []
  doc = Document.new(resp.body)
  
  XPath.each(doc, '//event') { |el| events << Event.create_from_node(el) }
  
  events
end

.valid_params?(params) ⇒ Boolean

Returns:

  • (Boolean)


85
86
# File 'lib/upcoming/event.rb', line 85

def self.valid_params?(params)
end

Instance Method Details

#add_tags(tag_list) ⇒ Object



59
60
61
# File 'lib/upcoming/event.rb', line 59

def add_tags(tag_list)
  # TODO implement add_tag
end

#categoryObject



39
40
41
# File 'lib/upcoming/event.rb', line 39

def category
  # TODO populate me intelligently
end

#countryObject



55
56
57
# File 'lib/upcoming/event.rb', line 55

def country
  # TODO get country info for event
end

#metroObject



47
48
49
# File 'lib/upcoming/event.rb', line 47

def metro
  # TODO get metro info for event
end

#remove_tag(tag) ⇒ Object



63
64
65
# File 'lib/upcoming/event.rb', line 63

def remove_tag(tag)
  # TODO implement remove_tag
end

#stateObject



51
52
53
# File 'lib/upcoming/event.rb', line 51

def state
  # TODO get state info for event
end

#userObject



35
36
37
# File 'lib/upcoming/event.rb', line 35

def user
  # TODO get user info about event
end

#venueObject



43
44
45
# File 'lib/upcoming/event.rb', line 43

def venue
  Upcoming::Venue.info(@venue_id)
end