Symbols & Methods Flashcards
To learn the basics of Ruby symbols and function, so that I may read code
#
octothrope - used to make a comment
{$0}
From command line, the name of the script you are running
{variable}
used for interpolation of a variable / to include your variable that doesn’t have information in it yet
$
attaches a variable from the command line
%
Modulo that returns the remainder in division
%d
represents a digit in a text string
%s
represents a string of text in a test string
( )
used to encapsulate arguments
*
multiplication
+
addition
-
subtraction
/
division
<
less than
«TEXT TEXT
to start and end a chunk of code that will not be read by ruby
<=
less than or equal to
>
greater than
> =
greater than or equal to
ARGV
argument value, holds arguments held on the cmd line
File
used as a method to define and enact file options
File.close()
closes a file
File.exists?
check to see if a file exists or not
File.open()
opens a file
File.open(filename, ‘w’)
Specifically opens a file for writing
File.read()
reads the contents of a file
File.readline()
reads a numbered line on a file
File.seek()
locate a particular spot in the file
File.truncate()
remove the contents of a file
File.write()
write line or characters to a file
STDIN
used when ARGV is used to get input from the user
[ ]
array
\
permits on backslash
\n
new line
\t
adds tab space
chomp
used w/gets to get info
do
reflects the start of a block of code to be run together
end
closes a block section of code
gets
takes input
open
open a file or url
takes text and prints it on the screen
puts
used to “put” a “string” of characters on the screen along with a new line
variable
a value stored