Upload
phungtu
View
281
Download
0
Embed Size (px)
Citation preview
documentation DocumentationPublicación 1.0
robdayz
16 de June de 2014
Índice general
1. other 31.1. Atenea1x1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2. plone 5
3. Moodle Manual 73.1. Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.2. file config.php . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4. atenea 114.1. Curso aparece cerrado a estudiantes y profesores . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5. asepeyo 135.1. Listado de máquinas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.2. Borrar SCORMS ocultos (en gris) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.3. Usuario estaba en un curso y ahora no aparece . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145.4. Desconfiguración en fórmula curso . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145.5. El report de encuestas muestra 0, en cambio hay varias realizadas . . . . . . . . . . . . . . . . . . . 145.6. Acceder al cron del sistema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155.7. Problemas al importar la BBDD de producción . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155.8. Cambiar contraseña a usuario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
6. andorra 176.1. Añadir un módulo nuevo en entorno de Andorra . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
7. pyramid 197.1. Installing Pyramid environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197.2. Running with virtualenv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
8. Canvas 218.1. Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218.2. FAST URL’s ACCESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
9. Rails 259.1. CodeSchool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
10. Ruby 2710.1. CodeSchool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
I
11. Indices and tables 33
II
documentation Documentation, Publicación 1.0
Aquí se adjunta un compendio de documentos útiles en el día a día :)
A ver que tal va...
Los cambios se compilan y suben directamente al repositorio de readthedocs.org en:
http://robdayz.readthedocs.org/
Para generar el preview del código pasado a HTML en local, es necesario instalar (en UBUNTU):
apt-get install python-sphinx
Y luego ejecutar:
make html
Índice general 1
documentation Documentation, Publicación 1.0
2 Índice general
CAPÍTULO 1
other
Let’s talk about a lot of thinks!
1.1 Atenea1x1
La url cal mirar id del lloc a internet ;) La url d’ún dels IES és així:
http://atenea1x1.educat1x1.cat/08071226/moodle
La base de dades es troba al servidor YED
3
documentation Documentation, Publicación 1.0
4 Capítulo 1. other
CAPÍTULO 2
plone
Let’s talk about Plone!
5
documentation Documentation, Publicación 1.0
6 Capítulo 2. plone
CAPÍTULO 3
Moodle Manual
Let’s talk about Moodle!
Nota: Updated to Moodle 2.6.3 and Ubuntu 14.10 with Postgres 9.3.
3.1 Installation
Nota: Original doc link: http://ubuntuserverguide.com/2012/11/how-to-install-moodle-on-ubuntu-server-12-04.html
# Update the system:
sudo apt-get install php5-intl php5-curl
# Download latest moodle:
wget -O moodle-latest.tgz http://sourceforge.net/projects/moodle/files/Moodle/stable26/moodle-latest-26.tgz/download
# Uncompress:
tar -zxvf moodle-latest.tgz
# Move to apache dir:
sudo mv moodle2.6.3 /var/www
# Change owner:
sudo chown -R www-data:www-data /var/www/moodle2.6.3/
# Create directory for moodle data, then set access directory moodle data to user and group:
sudo mkdir /var/moodledatasudo chown -R www-data:www-data /var/moodledata
# Create MYSQL DATABASE:
mysql -u root -pCREATE DATABASE dbmoodle;ALTER DATABASE dbmoodle charset=utf8;CREATE USER moodleuser;
SET PASSWORD FOR moodleuser = PASSWORD("moodlepass");
7
documentation Documentation, Publicación 1.0
GRANT ALL PRIVILEGES ON dbmoodle.* TO moodleuser@localhost IDENTIFIED BY "moodlepass";quit
# Continue process by web:
http://127.0.0.1/moodle2.6.3
*Select MySQL or PostGres*
#For Mysql:
sudo apt-get install mysql-server php5-mysql
#For Postgresql 9.3:
sudo apt-get install postgresql-9.3 php5-pgsqlsudo apt-get install postgresql-client-commonsudo apt-get install postgresql postgresql-contrib
sudo -u postgres createuser -D -A -P moodleusersudo -u postgres createdb -E utf8 -O moodleuser moodle
Change pasword:::# ALTER USER postgres WITH PASSWORD ’NewAdminDatabasePassword’;# \q
# Restart the database:
sudo /etc/init.d/postgresql restart
Nota: Created values: USERNAME:moodleuser PASSWORD:moodle
And TEST MOODLE PASSWORD: admin.atenea / 123QWEasd@
3.2 file config.php
This is the created config.php after installation:
<?php // Moodle configuration file
unset($CFG);global $CFG;$CFG = new stdClass();
$CFG->dbtype = ’pgsql’;$CFG->dblibrary = ’native’;$CFG->dbhost = ’localhost’;$CFG->dbname = ’moodle’;$CFG->dbuser = ’moodleuser’;$CFG->dbpass = ’moodle’;$CFG->prefix = ’mdl_’;$CFG->dboptions = array (
’dbpersist’ => 0,’dbport’ => ’’,’dbsocket’ => ’’,
);
8 Capítulo 3. Moodle Manual
documentation Documentation, Publicación 1.0
$CFG->wwwroot = ’http://localhost/moodle2.6.3’;$CFG->dataroot = ’/var/moodledata’;$CFG->admin = ’admin’;
$CFG->directorypermissions = 0777;
require_once(dirname(__FILE__) . ’/lib/setup.php’);
// There is no php closing tag in this file,// it is intentional because it prevents trailing whitespace problems!
3.2. file config.php 9
documentation Documentation, Publicación 1.0
10 Capítulo 3. Moodle Manual
CAPÍTULO 4
atenea
Temas relacionados con el Moodle de AteneaUPC
4.1 Curso aparece cerrado a estudiantes y profesores
Editar parámetros del curso y en donde pone “Disponibilitat”, cambiarlo.
11
documentation Documentation, Publicación 1.0
12 Capítulo 4. atenea
CAPÍTULO 5
asepeyo
5.1 Listado de máquinas
NAME URL & PATHProducción DB: tureis /DADES/htdocs/moodle_asepeyo
FE: pineda1 http://ucapren.asepeyo.esFE: pineda2 http://ucapren.asepeyo.es
Preproducción DB: comanegra /usr/local/nginx/htdocs/moodle/local/asepeyoFE: comanegra http://uca.test.upcnet.es/moodle/
PRE User moodle
PRO User moodle
5.2 Borrar SCORMS ocultos (en gris)
Problema: Al copiar los SCORMS se han duplicado los elementos “cualificables”. Hay que eliminarlos. La usuariaa puesto en oculto los repetidos para que no molesten al formador.
Solución:
Acceder a la web: http://ucapren.asepeyo.es/
Validarse
Acceder al Curso (ISAMXXX): http://ucapren.asepeyo.es/course/search.php?search=
En la parte de la derecha, clicar en Calificaciones
En el combo, desplegar “Vista completa”
En la url aparece al final el ID del course: http://ucapren.asepeyo.es/grade/edit/tree/index.php?showadvanced=1&id=4076
EJEMPLO: Recordar el 4076
Encima del elemento oculto, obtener la url (en este caso) http://ucapren.asepeyo.es/mod/scorm/grade.php?id=7389&itemnumber=1188
EJEMPLO: Memorizar el ID 1188
Abrir el pgAdminIII
Conectar a TUREIS / moodle_asepeyo / tables / mdl_grade_items.
Clicar icono de la tabla (View the data in the selected object).
13
documentation Documentation, Publicación 1.0
Clicar el icono del embudo.
En la pestaña filter, poner: courseid = 4076 (número del curso anteriormente memorizado).
Encontrar el que pone: itemnumber = 1188 (del ejemplo).
En la barra de números de la izquierda, botón derecho, delete.
El elemento duplicado desaparece de la web.
5.3 Usuario estaba en un curso y ahora no aparece
Problema: Un usuario podía acceder a un curso y ahora ya no aparece en él
Solución:
Acceder al curso
Comprobar que el usuario está en el curso matriculado. En el curso, en la derecha, clicar en Partici-pantes y buscarlo
Comprobar si está en la lista de usuarios del sistema En el curso, abajo, en Ajustes / Usuarios / Usua-rios matriculados
Comprobar todos los usuarios de todos los cursos En el curso, abajo a la derecha, en Ajustes / Admi-nistración del sitio / Usuarios / Cuentas / Hojear lista de usuarios
Ahora mirar si se ha hecho la baja del curro (de Meta4): Ajustes / Administración del sitio / Atenea /Maintenance / Queues e indicar el id del curso y buscar
*Aquí no aparece! –> Éste es el problema!*
http://ucapren.asepeyo.es/local/atenea/cues/monitorcues.php
5.4 Desconfiguración en fórmula curso
Problema: La fórmula del usuario muestra “error” como nota final
Solución:
Acceder al curso
Clicar en cualificaciones
En el desplegable escoger “Lista completa”
Aparecen los objetos cualificables del curso, en el último, en la calculadora, clicar sobre el icono calcula-dora.
Aquí se puede ver que uno de los elementos de la fórmula no existe (los pone con asteriscos), hay queasignarlo a mano
5.5 El report de encuestas muestra 0, en cambio hay varias realiza-das
Problema: Si accedes al report ves que dice 0 pero realmente en la plantilla se ven resultados
Solución:
14 Capítulo 5. asepeyo
documentation Documentation, Publicación 1.0
Añadir el literal “$string[’startcomplete’] = ‘Se ha visualizado’;” en los ficheros:report/technical_office/lang/es/report_technical_office.php report/technical_office/lang/es/report_technical_office.php
5.6 Acceder al cron del sistema
El de producción: http://ucapren.asepeyo.es/admin/cron.php
El de test: http://uca.test.upcnet.es/moodle/admin/cron.php
5.7 Problemas al importar la BBDD de producción
Problema:
psql:/Dades/moodledata/pgsql_backup_moodle_asepeyo.res:1484074: ERROR: could not create uniqueindex “mdl_cont_conins_uix” DETAIL: Table contains duplicated values.
Solución
Buscar el elemento repetido y lanzar de nuevo la query sql:
CREATE UNIQUE INDEX mdl_cont_conins_uix ON mdl_context USING btree (contextlevel , ins-tanceid );
—SELECT id , contextlevel , instanceid –FROM mdl_context –WHERE contextlevel=10 and instanceid= 0 –GROUP BY contextlevel , instanceid –HAVING COUNT (*) >1 –ORDER BY contextlevel
5.8 Cambiar contraseña a usuario
Problema
El usuario no puede entrar en el sistema
Solución
Acceder a pgAdmin En moodle_asepeyo / mdl_user buscar por idnumber = ‘DNI_NUMBER’ Realizar laquery y “memorizar” el id del usuario Ir a la web (moodle) acceder al perfil de un usuario. Y cambiar elID por el campo ID memorizado de la BBDD: http://ucapren.asepeyo.es/user/view.php?id=XXXX
5.6. Acceder al cron del sistema 15
documentation Documentation, Publicación 1.0
16 Capítulo 5. asepeyo
CAPÍTULO 6
andorra
Let’s talk about Andorra!
6.1 Añadir un módulo nuevo en entorno de Andorra
1.- Acceder a: superba1 / superba2 / superba5 / superba6
2.- Descargar el módulo y descomprimirlo 3.- Copiarlo en la carpeta de los módulos, tanto en mas-ter_moodle como en educació:
/usr/local/nginx/htdocs/moodle_andorra/educacio/mod/ /usr/local/nginx/htdocs/moodle_andorra/master_andorra/mod/
4.- Acceder a la parte de notificaciones y guardar: http://www.educand.ad/educacio/admin/index.php
5.- Hay que hacerlo para todas las escuelas que aparecen en: http://www.educand.ad/educacio/ (loslinks que hay más abajo)
17
documentation Documentation, Publicación 1.0
18 Capítulo 6. andorra
CAPÍTULO 7
pyramid
Let’s talk about Pyramid!
7.1 Installing Pyramid environment
Installing Pyramid and running default Project:
/var/plone/python2.7/bin/pip install pyramid
/var/plone/python2.7/bin/pip install Paste
/var/plone/python2.7/bin/pip install waitress
/var/plone/python2.7/bin/pcreate -s alchemy MyProject
cd MyProject
/var/plone/python2.7/bin/python setup.py develop
cd..
/var/plone/python2.7/bin/initialize_MyProject_db MyProject/development.ini
/var/plone/python2.7/bin/pserve MyProject/development.ini
7.2 Running with virtualenv
This is the procedure for working with Pyramid in an Virtualenv environment:
/var/plone/python2.7/bin/pip install virtualenv /var/plone/python.27/bin/virtualenv/var/plone/pyramid/racc cd /var/plone/pyramid/racc cd racc.goals source bin/activate ../bin/pip ins-tall pyramid ../bin/python2.7 setup.py develop ../bin/pserve development.ini
To exit from Virtualenv environment: desactivate
19
documentation Documentation, Publicación 1.0
20 Capítulo 7. pyramid
CAPÍTULO 8
Canvas
8.1 Installation
8.1.1 0. Create user canvas and initial environment config
$ sudo su$ adduser canvas$ mkdir /var/canvas$ cd /var$ chown canvas.canvas canvas$ su canvas$ cd canvas$ mkdir gems
Add to file and exit:canvas ALL=(ALL:ALL) ALL
$ su canvas$ cd canvas
8.1.2 Installing GIT
$ sudo apt-get install git-core$ git clone https://github.com/instructure/canvas-lms.git canvas$ cd canvas$ git checkout --track -b stable origin/stable <-- Gives us an error
8.1.3 Installing RUBY
$ sudo apt-get install ruby1.9.1 ruby1.9.1-dev zlib1g-dev rubygems1.9.1 libxml2-dev libxslt1-dev \libsqlite3-dev libhttpclient-ruby imagemagick irb1.9.1 coffeescript \libxmlsec1-dev postgresql
8.1.4 Installing Node.js
21
documentation Documentation, Publicación 1.0
$ sudo add-apt-repository ppa:chris-lea/node.js -y$ sudo apt-get update || sudo apt-get install nodejs -y
8.1.5 Installing Gems
$ sudo vi /etc/environmentAnd add to the bottom of the file$ GEM_HOME=/var/canvas/gems
And then install bundler:
$ sudo gem install bundler
If you are running with POSTGRES (our case):
$ cd /var/canvas/canvas$ sudo apt-get install libcurl4-gnutls-dev g++ libpq-dev -y$ sudo ..gems/bin/bundle install --without mysql
And then from the canvas directory, launch this command:
$ for config in amazon_s3 delayed_jobs domain file_store outgoing_mail security scribd external_migration; \do cp config/$config.yml.example config/$config.yml; done
8.1.6 DATA SETUP
$ cp config/database.yml.example config/database.yml$ sudo -u postgres createuser canvas --no-createdb --no-superuser --no-createrole --pwprompt
*** Asks password for the new role --> canvas***
$ sudo -u postgres createdb canvas_production --owner=canvas$ sudo -u postgres createdb canvas_queue_production --owner=canvas$ sudo -u postgres createdb canvas_development --owner=canvas$ sudo -u postgres createdb canvas_queue_development --owner=canvas
8.1.7 POPULATION
$ sudo./gems/bin/bundle exec rake db:initial_setup
***ERROR***Follow this steps. Modify file (line 147) and relaunch previous command:
‘‘ https://github.com/padwasabimasala/canvas-lms/commit/e26d675ea8abdb6dbd0f4f57eb290a5a262fe200 ‘‘
During this process the system asks:1.- Which email address site administration account use2.- Confirm mail3.- Password admin account4.- Confirm password5.- Account name6.- Send data ->2
And finally start the new Canvas Site:
22 Capítulo 8. Canvas
documentation Documentation, Publicación 1.0
$ $GEM_HOME/bin/bundle exec script/server
8.2 FAST URL’s ACCESS
Content Imports -> https://xxxxx/courses/XXX/imports.
Content Import / Current Migrations -> https://xxxxxx/courses/XXX/imports/list.
Migrate from another system -> https://xxxxxx/courses/XXX/imports/migrate.
SIS IMPORT -> https://xxxxxx/accounts/1/sis_import.
LOG ERROR -> https://xxxxxx/error_reports.
8.2. FAST URL’s ACCESS 23
documentation Documentation, Publicación 1.0
24 Capítulo 8. Canvas
CAPÍTULO 9
Rails
9.1 CodeSchool
9.1.1 Level 1
Rails for zombies - 5:57 http://railsforzombies.org/levels/1
t.Tweet.find(3)
puts t[:id] –> 3
puts t[:status] –> “I just ate...”
puts t[:zombie] –> “Jim”
puts t.id puts t.status puts t.zombie
9.1.2 Create
t = Tweet.new t.status = “Hello” t.save
t = Tweet.new(:status => “Hello”, :zombie => “Jim”) t.save
Tweet.create(:status => “Hello”, :zombie => “Jim”)
9.1.3 Read/Find
Tweet.find(2) Tweet.find(3,4,5) Tweet.first Tweet.last Tweet.all Tweet.count Tweet.order(:zombie)Tweet.limit(10) Tweet.where(:zombie=>”ash”) Tweet.where(:zombie=>”ash”).order(:zombie).limit(10)
9.1.4 Update
t = Tweet.find(3) t.zombie = “Jim” t.save
t.attributes = { :status => “Good”, :zombie => “Blo”} t.save
# Guarda de manera automatica t.update_attributes = { :status => “Good”, :zombie => “Blo”}
25
documentation Documentation, Publicación 1.0
9.1.5 Delete
t = Tweet.find(3) t.destroy
Tweet.find(3).destroy
Tweet.destroy_all
9.1.6 Testing:
t = Zombie.find(3) t.attributes = {:graveyard => “Benny Hills Memorial”} t.save
Zombie.find(3).destroy
9.1.7 Level 2
Rails for zombies - 5:45 http://railsforzombies.org/levels/2
app/models/tweet.rb
t = Tweet.find(3)class.method
class Tweet < ActiveRecord::Basevalidates_presence_of :status
end
t.Tweet.newt.savet.errors --> Shows validationt.errors[:status]
validates_inclusion_of :age, in: => 10..21, :message => "Sorry..."
validates :status, :presence => truevalidates :status, :length => [:minimun => 3}
validates :status, :presence => true, :length => [:minimun => 3}
9.1.8 A Tweet belong to a Zombie
class Tweet < ActiveRecord::Basebelongs_to :zombie
end
26 Capítulo 9. Rails
CAPÍTULO 10
Ruby
10.1 CodeSchool
10.1.1 Notes
40.to_s.reverseto_s converts things to strings.to_i converts things to integers (numbers.)to_a converts things to arrays.
Replace first occurence:
poem[’toast’] = ’honeydew’
poem.lines.to_a.reverse
Dictionary --> books= {}
Ratings --> ratings = Hash.new(0)
5.times { print "Odelay!" }
Dir["/*.txt"]print File.read("/comics.txt")FileUtils.cp(’/comics.txt’, ’/Home/comics.txt’)File.open("/Home/comics.txt", "a") do |f|
f << "Cat and Girl: http://catandgirl.com/"endprint File.read("/Home/comics.txt")File.mtime("/Home/comics.txt")File.mtime("/Home/comics.txt").hour
def load_comics( path )comics = {}File.foreach(path) do |line|name, url = line.split(’: ’)comics[name] = url.strip
endcomics
27
documentation Documentation, Publicación 1.0
end
require ’popup’Popup.goto "http://ruby-lang.org"
Popup.make {h1 "My Links"link "Go to Ruby", "http://ruby-lang.org/"
}
Popup.make doh1 "Things To Do"list dop "Try out Ruby"p "Ride a tiger"p "(down River Euphrates)"
endend
Popup.make doh1 "Comics on the Web"list docomics.each do |name, url|
link name, urlend
endend
class BlogEntryattr_accessor :title, :time, :fulltext, :mood
end
entry = BlogEntry.newentry.title = "Today Mt. Hood Was Stolen!"entry.time = Time.nowentry.mood = :sickentry.fulltext = "I can’t believe Mt. Hood was stolen! I am speechless! It was stolen by a giraffe who drove away in his Cadillac Seville very nonchalant!!"
class BlogEntrydef initialize( title, mood, fulltext )@time = Time.now@title, @mood, @fulltext = title, mood, fulltext
endend
entry2 = BlogEntry.new("I Left my Hoodie on the Mountain!", :confused, "I am never going back to that mountain and I hope a giraffe steals it.")
10.1.2 Boys are Different From Girls
Objective:
And numbers are different from strings. While you can use methods on any object in Ruby, some methods only workon certain types of things. But you can always convert between different types using Ruby’s “to” methods.
28 Capítulo 10. Ruby
documentation Documentation, Publicación 1.0
to_s converts things to strings. to_i converts things to integers (numbers.) to_a converts things to arrays.
What are arrays?! They are lists. Type in a pair of brackets: [].
10.1.3 Standing in Line
Great, that’s an empty list. Lists store things in order. Like standing in line for popcorn. You are behind someone andyou wouldn’t dream of pushing them aside, right? And the guy behind you, you’ve got a close eye on him, right?
Here’s a list for you. Lottery numbers: [12, 47, 35].
10.1.4 One Raises Its Hand
A list of lottery numbers. Which one is the highest?
Try: [12, 47, 35].max.
10.1.5 Tucking a List Away
Good, good. But it’s annoying to have to retype that list, isn’t it?
Let’s save our numbers inside a ticket like so: ticket = [12, 47, 35]
10.1.6 Summary #2 is Upon Us
You had a list. You sorted the list. The ticket variable is now changed.
Did you notice that the sort! method has a big, bright exclamation at the end? A lot of times Ruby methods shout likethat if they change what the variable contains for good. It’s nothin’ special, just a mark.
Now, look how your second minute went:
Errors. If you try to reverse a number or do anything fishy, Ruby will skip the prompt and tell you so.Arrays are lists for storing things in order. Variables save a thing and give it a name. You used the equalssign to do this. Like: ticket = [14, 37, 18].
In all there are eight lessons. You are two-eighths of the way there! This is simple stuff, don’t you think? Good stuffup ahead.
Let’s change directions for a moment. I’ve stuffed a bit of poetry for you in a certain variable. Take a look. Type printpoem
10.1.7 Ringlets of Chained Methods
Objective:
So what do you see? What happened there? You typed poem.lines.to_a.reverse and what happened?
Two things happened. You turned the poem into a list using lines.to_a. lines decides the way the string is split up, thento_a converted it into an Array. (To array.) Different methods, such as bytes and chars can be used in place of lines.By using lines, ruby will return each line of the poem.
Then, you reversed that list. You had each line. You reversed them. That’s it.
Let’s tack one more method on the end there: print poem.lines.to_a.reverse.join
10.1. CodeSchool 29
documentation Documentation, Publicación 1.0
10.1.8 Of All the Summaries, #3 is Here Now
Objective:
Good show, my friend! The join method took that list of reversed lines and put them together into a string. (Sure, youcould have also just used to_s.)
Review time.
Exclamations. Methods may have exclamations (and also question marks) in their name. No big deal. Try:poem.include? “my hand” Square brackets. Target and find things. Search and replace. Chaining methodslets you get a lot more done. Break up a poem, reverse it, reassemble it: poem.lines.to_a.reverse.join
At this point, you may want to tinker with the poem a bit more. A complete list of all the String methods is here. Goahead and try a few (such as poem.downcase or poem.delete.)
When you’re ready to move on, type: books = {}
10.1.9 A Wee Blank Book
Objective:
You’ve made an empty hash. (Also known as: an empty dictionary.)
We’re going to stuff some miniature book reviews in this hash. Here’s our rating system:
:splendid → a masterpiece. :quite_good → enjoyed, sure, yes. :mediocre → equal parts great and terrible.:quite_not_good → notably bad. :abysmal → steaming wreck.
To rate a book, put the title in square brackets and put the rating after the equals.
For example: books[”Gravity’s Rainbow”] = :splendid
10.1.10 Are You Harsh?
Objective:
Then, okay, now let’s count up your reviews. Just stay with me. Type: books.values.each
(The straight line in the code is the pipe character, probably located right above the Enter key on your keyboard.)
After that, type ratings to see the count. This new hash shows a rating and then the number of times you’ve given thatrating.
When you want to move on, type next
10.1.11 Now Arriving at Summary #4
Objective:
Blocks are always attached to methods. Like the times method, which takes the block and runs the code over and over.(In this case: five times.)
This last lesson was a bit longer. You’ve probably used up three minutes learning about:
Hashes. The little dictionary with the curly pages Symbols. Tiny, efficient code words with a colon::splendid. Blocks. Chunks of code which can be tacked on to many of Ruby’s methods. Here’s the codeyou used to build a scorecard: books.values.each.
30 Capítulo 10. Ruby
documentation Documentation, Publicación 1.0
On your computer, you probably have a lot of different files. Files with pictures in them, files with programs in them.And files are often organized into folders, also called: directories.
I’ve prepared a few directories for you. Take a look: Dir.entries “/”
10.1.12 Summary #6 Which Means You’ve Come So Far
Objective:
You’re a level six Ruby cleric. I mean what a great job you’ve done. Let’s review:
You added your own method with def and you used that load_comics method several times. Libraries. Youused the require method to load the popup library. By typing: require ‘popup’ And if that wasn’t enough,you made your own web page from a list of comics in a file. You made a real program!
So what could possibly be next? What could you possibly have to learn now? Ha, this is the best part. You’ve comesuch a long way that we’re going to uncover classes. For two more short lessons and you’re done.
Earlier, we created a hash like this: Hash.new Try it.
10.1.13 A Giraffe Has Not Stolen Summary #7
Objective:
Aha, you’re here. And all in one piece. We’re still going to make your blog real, but until then, let’s review, okay?
Classes. Everything in Ruby is some kind of object. Classes explain objects. How a certain object works.For example, you made a few blog entry objects and these objects are explained in the BlogEntry class.In other words: you call them BlogEntry objects. Accessors are variables attached to an object which canbe used outside the object. (entry.time = Time.now) Instance variables are the same variables you’re usingfor accessors when inside the object. Like in a method definition. (@time = Time.now)
Okay, let’s wrap things up, kid. Here’s the last chapter of the GRIPPING epic story of Try Ruby! Now that you’ve gota taste of how it all works, how are you going to use it around the house and in your grocer’s freezer? You’re a greatperson (one of my favorites), but you need guidance.
Let’s finish your blog. You have blog entries, but no actual blog.
Put the entries into an array: blog = [entry, entry2]
When you want to move on, type next
10.1. CodeSchool 31
documentation Documentation, Publicación 1.0
32 Capítulo 10. Ruby
CAPÍTULO 11
Indices and tables
genindex
modindex
search
33