Please enable JavaScript.
Coggle requires JavaScript to display documents.
RUBY is?; an open source language that focuses on ease of use and is made…
RUBY is?; an open source language that focuses on ease of use and is made of objects and variables
class
methods
(are provided by the class. the string class has certain methods, same for array, and etc)
self.blahblah
is the same as this in javascript. references the calling object/class
RAILS
MVC
view
what user interacts with. css/javascript/html
controller
responds to user events, and makes changes to model+view based on that.
model
objects/data in database
rails is built on this fundamental architecture
Objects (aka instances) are?; data structures that consist of data + methods that are bound together. Data = things like strings and numbers. Methods = a set of expressions that returns a value. Methods are bound to objects and can be inside a class or outside of a class.
Class is a?; predefined object that contains data (classes like fixnum and string) and methods (string.new). Anything you can do to an object you can do to Class as well classes within Class.
classes are?; objects that consist of characteristics (data) and functions (methods). they are called instances of Class. They should really be called subclasses, but for some god forsaken reason the creator(s) of ruby decided to just name them class.
Objects in a class (subclass) are?; instances of the class (subclass). They contain data + methods. An analogy to the real world would by the abstract concept of bicycles (a class) which contains all the physical bicycles that people own/buy (these would be objects)
Getter is an?; object method inside a class.
setter
attr_writer :variable
writes but won't read from a class
is how you change a value from a class when outside it
def variable= lets ruby know this is a setter method
Getter
attr_reader :variable
reads but won't write to a class
is how you retrieve a value from a class when outside it
Getter + setter
attr_accessor :variable
Setter is an?; object method inside a class.
Getter + Setter is an?; object method inside a class.
https://imgur.com/Dp8yCej
variables are?; not technically an object, but rather like a label representing an object. Aka "pointers"
local variable
(disappears after method call is over)
class variable (prefix /w @ @ )
the @ symbol becomes part of the variable name from now on when you want to reference it
tied to the class, not the instance/object
instance variable (prefix with @ )
keeps value between method calls, but only inside the class
global variable
Modules???
examples of classes:
hash
string
fixnum (number)
class