-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cd0818
commit 1f901d2
Showing
2 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'open-uri' | ||
|
||
open("http://www.ruby-lang.org/en") do |f| | ||
# f.each_line {|line| p line} | ||
puts f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/> | ||
puts f.content_type # "text/html: | ||
puts f.charset # "iso-885901" | ||
puts f.content_encoding # [] | ||
puts f.last_modified # Thu Dec 05 02:45:02 UTC 2002 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
puts | ||
prints a line of text | ||
followed by a new line | ||
|
||
" " | ||
double quote | ||
make a string by surrounding something with quotes | ||
|
||
, | ||
comma | ||
apparently this separates a string from something else such as a math operation | ||
|
||
# | ||
comment | ||
anything after one of these will be ignored by ruby | ||
|
||
+ | ||
add | ||
|
||
/ | ||
divide | ||
|
||
% | ||
percent | ||
gets the percent of something 10 % 100 is 10 | ||
|
||
< > | ||
less than, greater than | ||
|
||
<= >= | ||
less than or equal to, greater than or equal to | ||
|
||
= | ||
equals | ||
assign a variable to something | ||
|
||
#{} | ||
embed a variable in a string like this "this is a string and a #{variable} | ||
|
||
%s | ||
format string | ||
embed a variable in a string like this "this is a string and a %s" % variable | ||
|
||
' ' | ||
single quote | ||
make a string by surrounding something with quotes | ||
|
||
puts "." * 10 # put something 10 times | ||
|
||
similar to puts, prints something, but doesn't end with a newline | ||
|
||
[ ] | ||
square brackets | ||
used with format strings like % [my_eyes, my_hair] | ||
|
||
, | ||
comma | ||
this separates arguments such as [1, 2, 3, 4] | ||
|
||
\ | ||
escape character | ||
allows you to use a special character as if it's not special, as its normal non special self | ||
<< | ||
multi-line string | ||
allows you to for instance puts a long string | ||
() | ||
parentheses | ||
you can pass arguments into functions within these parentheses like new_function(argument1, argument2) | ||
ARGV | ||
the argument variable | ||
all caps because it's a constant | ||
can't change it once it's assigned | ||
the arguments you provide when you run your ruby script are assigned to this variable ARGV | ||
|
||
STDIN | ||
standard input | ||
|
||
gets | ||
reads the next line from the IO stream | ||
|
||
chomp() | ||
by default removes carriage return characters | ||
removes the given record separator | ||
|
||
ARGV.first | ||
the first argument that was passed into the script when the script was run | ||
|
||
File.open(filename) | ||
returns the value of the block? | ||
this opens a file and assigns it some special code | ||
|
||
txt.read() | ||
read whatever's in txt | ||
|
||
$0 | ||
variable which is assigned the name of the script | ||
|
||
CTRL-C | ||
abort | ||
|
||
|