Ruby

Is being followed by 0 users

There are 1512 cards with this tag.

There are 4 decks with cards that have this tag.

Created by: Jack Kinsella

Ruby: How do you get the ID for an object

.object_id

Created by: Jack Kinsella

How do you get the name of the class of an object

.class

Created by: Jack Kinsella

how to write a dsl which shoots out a message if code in a block is true

dsl:
event "we're earning money" {recent_order > 1000 }

def event(name)
puts name if yield
end

Dir.glob('*events.rb').each {|file| load_file}

Created by: Jack Kinsella

a = [1, 2, 3]

a.permutation(2).to_a

two element arrays
[[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]

Created by: Jack Kinsella

ruby - how to get response code on a NetHTTP response object

.code

Created by: Jack Kinsella

How do make a regular expression match beginning and end of a string

\A - for beginning
\z - for end of string

Created by: Jack Kinsella

A method which is specific to a single object is called a ...

singleton method

Created by: Jack Kinsella

Concatenate arrays together

array1 + array2 or

array1.concat( array2 )

Created by: Jack Kinsella

how to assign an exception object (ArgumentError) to the variable exp

rescue ArgumentError => exp

Created by: Jack Kinsella

in ruby 1.9, what is a concise syntax for named arguments

login(name: 'bill', code: 45)

# actually this is the concise syntax for hashes with symbol keys

Created by: Jack Kinsella

what is a class variable (as opposed to a class instance variable)

class C
@@v = 1
end

this is a class variable (@v = instance var)

Created by: Jack Kinsella

ruby - copy many files to a "backup" dir

FileUtils.cp(["file1", "file2"], "backup")

  • There are 1512 results.

You must be logged in to perform this action.

Login now

×

Deck Management

You must be logged in to perform this action.

Login now

Done ×

Deck Management

You must be logged in to perform this action.

Login now

Done ×

Deck Management

You must be logged in to perform this action.

Login now

Done ×

Deck Management

You must be logged in to perform this action.

Login now

Done ×

Deck Management

You must be logged in to perform this action.

Login now

Done ×

Deck Management

You must be logged in to perform this action.

Login now

Done ×

Deck Management

You must be logged in to perform this action.

Login now

Done ×

Deck Management

You must be logged in to perform this action.

Login now

Done ×

Deck Management

You must be logged in to perform this action.

Login now

Done ×

Deck Management

You must be logged in to perform this action.

Login now

Done ×

Deck Management

You must be logged in to perform this action.

Login now

Done ×

Deck Management

You must be logged in to perform this action.

Login now

Done ×