class LaunchPass::User

Attributes

avatar_url[R]
email[R]
first_name[R]
last_name[R]
username[R]

Public Class Methods

new(info_hash) click to toggle source
# File lib/launch_pass/user.rb, line 9
def initialize(info_hash)
  @info_hash = info_hash
  @email = @info_hash["email"]
  @first_name = @info_hash["first_name"]
  @last_name = @info_hash["last_name"]
  @avatar_url = @info_hash["avatar_url"]
  @username = @info_hash["username"]
end

Public Instance Methods

admin?() click to toggle source
# File lib/launch_pass/user.rb, line 33
def admin?
  member_of?('Admins')
end
has_product?(product_name, wildcard = true) click to toggle source
# File lib/launch_pass/user.rb, line 22
def has_product?(product_name, wildcard = true)
  if !wildcard
    products.include?(product_name)
  else
    products.each do |product|
      return true if product =~ /#{Regexp.escape(product_name)}/
    end
    false
  end
end
member_of?(team_name) click to toggle source
# File lib/launch_pass/user.rb, line 18
def member_of?(team_name)
  teams.include?(team_name)
end
products() click to toggle source
# File lib/launch_pass/user.rb, line 45
def products
  if @info_hash["products"]
    @products ||= @info_hash["products"].map do |product|
      product["name"]
    end
  end
end
teams() click to toggle source
# File lib/launch_pass/user.rb, line 37
def teams
  if @info_hash["teams"]
    @teams ||= @info_hash["teams"].map do |team_hash|
      team_hash["name"]
    end
  end
end