T-11 to HW Due

  • EventManager 3 – Clean Phone Numbers
    • The sunlight API has a method built for gathering the first_name and last_name of a senator, which is applied to an object of a Legislator class
      • In our case this is an array of legislator objects.
    • the push method is an alternative to << for adding items to arrays
    • I can’t tell the difference between the method collect to the method map, generates the same output
    • adding an exclamation point to the gsub method results in the replacement of the original string rather than the manufacture of a new string
    • ERB is a template language, using ERB entails inserting escape sequence tags to a plain text document which will correlate to variables in your Ruby code (<%= stuff%>), much like interpolation with #{insert_me}. In addition to inserting a variable (output of a code), ERB escape tags can also execute and not show ruby code <% stuff %>
      • variable1 = "stuff" # string to be filled via ERB
      • then variable2 = ERB.new(variable1)
      • and lastly variable3 = variable2.result(binding)
        • this asks for the results of variable2, since variable2 does not visibly carry out its ERB tasks without it being asked to by binding; meaning that we could have other lines of code where ERB is used in a different way on the same string, but we could call different results with the binding method, and storing those results in a new variable rather than overwriting the old one, eradicating possibilities for interference
        • the method binding makes something an object of the class Binding
    • The Dir. command in Ruby will make some commands used in the terminal available. Some examples: Dir.chdir, Dir.mkdir, Dir.entries is the same as ls
    • File.open with the 'w' option has the power to overwrite another file that may have the same name.
    • Printing into a file is as easy as printing onto the screen, instead of the everyday Kernel.puts you use the file_obj.puts
    • If you want to use regular expressions to exclude a set of characters, use the carrot: /[^0-9]/i
    • the class method will return the class of the object (string, fixnum, array)
    • the slice!(index) method will remove a certain position in a string
    • when the csv module converts headers to symbols (takes the argument: header_converters: :symbol), those symbols should be referenced in all lowercase no matter how they are capitalized in the header

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s