3 minute read

Tonight I made some good progress on my CLI project. I finished watching Avi’s video on the project and it helped A LOT. It was long so I decided to just complete the basic stub of my project and leave it at that for tonight. I really like working with fake placeholder data for as long as possible. This way it’ll all hopefully just work when real data is passed in. So taking the stub I’m sharing below and abstracting that out to have objects holding the data for each meetup. Then building the methods to create those objects in another class.

What I have so far:

class MeetupsAround::CLI
  attr_reader :todays_date

  def call
    @todays_date = "Saturday, March 25"
    input_zipcode
    input_radius
    list_meetups
    again?
  end

  def input_zipcode
    puts "What zip code would you like to see meetups for?"
    zip_code = gets.strip
    if /\b\d{5}\b/.match?(zip_code)
      nil
    else
      puts "Please enter a five digit zip code."
      self.input_zipcode
    end
  end

  def input_radius
    puts "What radius around that zip code would you like to see meetups for?"
    radius = gets.strip
    if /\b\d{1,2}\b/.match?(radius)
      nil
    else
      puts "Please enter a radius less than 100."
      self.input_radius
    end
  end

  def list_meetups
    puts "Today #{todays_date} are the following meetups:"
    puts <<~HEREDOC
    1. 2:30PM - Developer Launchpad Nashville - Coding Jam - 19 Developers going
    2. 9:00AM - Score Nashville Events, Networking and Workshops - Join us for a "Start your Business" workshop! - 2 Members going
    3. 10:00AM - Paid to Speak Entrepreneurs - How To Get Your Speaking Career Started - 18 Members Going
    HEREDOC
  end

  def again?
    puts "Would you like to search again? [Y/N]"
    input = gets.strip.downcase
    puts input == "y" || input == "yes" ? call : "Goodbye =)"
  end

end

Next up I’ll change the HEREDOC block and utilize an object iteration to list each object. Something like:

meetups.each.with_index(1) do |meetup, i|
  puts "#{i}. #{meetup.time} - #{meetup.group} - #{meetup.event} - #{meetup.attendees}"
end  

Now I don’t know if this is exactly what I’ll end up with but it’s what I’m thinking at this point in time. I’ll also need to have an array with the meetup objects called meetups in this scenario. For this project I’m suppose to record myself coding for 30 minutes so I think when I go to tackle this I’ll do that recording. I’ll watch the video Avi made another time and get a solid plan of action down and then go for it. Pretty sure they don’t want a video of me watching videos hehe.

Tonight I also installed a couple more packages into Atom. Specifically minimap, seti-icons, atom-beautify, highlight-selected, pigments, minimap-highlight-selected, and minimap-pigments. I highly recommend them all so check them out.

Time spent today: 2:22
Time spent total: 110:57
Lessons completed today: 0
Lessons completed total: 285

comments powered by Disqus