Skip to content

Commit

Permalink
Update ruby talk
Browse files Browse the repository at this point in the history
  • Loading branch information
alkrauss48 committed Oct 8, 2019
1 parent 5cbe4cb commit 2689a11
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,39 @@
"## By Aaron Krauss"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"<img src=\"assets/clevyr.png\" style=\"width: 400px;\">"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Future of OKC Ruby"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# OKC Web Devs"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down Expand Up @@ -127,9 +160,8 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand Down Expand Up @@ -170,9 +202,8 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand Down Expand Up @@ -269,6 +300,68 @@
"This process is called **Monkeypatching**. It's not bad by any means, but be sure you know what you're doing."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# A Fix: Refinements"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"In Ruby 2.0 (back in 2010), Refinements were added."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"This adds 2 new keywords to the Module class: refine and using."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"%%capture\n",
"%%ruby\n",
"\n",
"module ReplaceMe\n",
" refine Array do\n",
" def replace(original, replacement)\n",
" self.map {|e| e == original ? replacement : e }\n",
" end\n",
" end\n",
"end\n",
"\n",
"puts ['x', 'y', 'z'].replace(['y'])\n",
"puts\n",
"\n",
"using ReplaceMe\n",
"\n",
"puts ['x', 'y', 'z'].replace('x', 'a')"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down Expand Up @@ -1018,16 +1111,22 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 1,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"80\n"
]
}
],
"source": [
"%%capture\n",
"%%ruby\n",
"\n",
"def lambda_example\n",
Expand Down Expand Up @@ -1451,7 +1550,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
103 changes: 98 additions & 5 deletions metaprogramming-ruby-talk/Metaprogramming with Ruby.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,39 @@
"## By Aaron Krauss"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"<img src=\"assets/clevyr.png\" style=\"width: 400px;\">"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Future of OKC Ruby"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# OKC Web Devs"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down Expand Up @@ -127,9 +160,8 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand Down Expand Up @@ -170,9 +202,8 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand Down Expand Up @@ -269,6 +300,68 @@
"This process is called **Monkeypatching**. It's not bad by any means, but be sure you know what you're doing."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# A Fix: Refinements"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"In Ruby 2.0 (back in 2010), Refinements were added."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"This adds 2 new keywords to the Module class: refine and using."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"%%capture\n",
"%%ruby\n",
"\n",
"module ReplaceMe\n",
" refine Array do\n",
" def replace(original, replacement)\n",
" self.map {|e| e == original ? replacement : e }\n",
" end\n",
" end\n",
"end\n",
"\n",
"puts ['x', 'y', 'z'].replace(['y'])\n",
"puts\n",
"\n",
"using ReplaceMe\n",
"\n",
"puts ['x', 'y', 'z'].replace('x', 'a')"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down Expand Up @@ -1457,7 +1550,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
Binary file added metaprogramming-ruby-talk/assets/clevyr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2689a11

Please sign in to comment.