class ClosestWeightliftingGem::Gym

Attributes

city[RW]
director[RW]
full_address[RW]
name[RW]
phone[RW]
state[RW]
street[RW]
website[RW]
zipcode[RW]

Public Class Methods

all() click to toggle source
# File lib/closest_weightlifting_gem/gym.rb, line 35
def self.all
  @@all
end
count_by_state() click to toggle source
# File lib/closest_weightlifting_gem/gym.rb, line 74
def self.count_by_state
  self.all.inject(Hash.new(0)) { |total, gym| total[gym.state] += 1 ; total }
end
find_by_name(input) click to toggle source
# File lib/closest_weightlifting_gem/gym.rb, line 57
def self.find_by_name(input)
  self.searches << { method: __method__, value: input }

  self.all.find_all { |gym| gym.name.upcase.include?(input.upcase) }
end
find_by_state(state) click to toggle source
# File lib/closest_weightlifting_gem/gym.rb, line 63
def self.find_by_state(state)
  self.searches << { method: __method__, value: state }

  self.all.find_all { |gym| gym.state == state.upcase }
end
new(gym_attributes) click to toggle source
# File lib/closest_weightlifting_gem/gym.rb, line 17
def initialize(gym_attributes)
  gym_attributes.each { |k,v| self.send(("#{k}="), v)}

  @@all << self
end
reset!() click to toggle source
# File lib/closest_weightlifting_gem/gym.rb, line 47
def self.reset!
  self.all.clear
end
searches() click to toggle source
# File lib/closest_weightlifting_gem/gym.rb, line 43
def self.searches
  @@searches
end
weird_gyms() click to toggle source
# File lib/closest_weightlifting_gem/gym.rb, line 51
def self.weird_gyms
  self.all.find_all do |g|
    g.phone.nil? || g.street.nil? || g.name.nil? || g.city.nil?
  end
end

Public Instance Methods

add_attributes(gym_attributes) click to toggle source
# File lib/closest_weightlifting_gem/gym.rb, line 23
def add_attributes(gym_attributes)
  gym_attributes.each { |k,v| self.send(("#{k}="), v)}
end