Class: Songkicky::User

Inherits:
Object
  • Object
show all
Includes:
JsonApi
Defined in:
lib/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from JsonApi

#all

Constructor Details

#initialize(username) ⇒ User

Returns a new instance of User.



14
15
16
17
# File 'lib/user.rb', line 14

def initialize(username)
  @username = username
  @past_events = nil
end

Class Method Details

.find_by_username(username) ⇒ Object

Raises:



8
9
10
11
# File 'lib/user.rb', line 8

def find_by_username(username)
  raise Error.new("Username is blank") if username.nil? || username.strip == ''
  User.new(username)
end

Instance Method Details

#past_eventsObject



19
20
21
22
23
24
# File 'lib/user.rb', line 19

def past_events
  return @past_events if @past_events

  events_hash = all("users/#{@username}/gigography.json", 'event')
  @past_events = events_hash.map {|hash| Event.new(hash) }
end