Skip to content

Commit

Permalink
Uhm. Fuck if statements, lets just roll with this!
Browse files Browse the repository at this point in the history
I've been awake way too long >.<
  • Loading branch information
JoshCheek committed Apr 15, 2015
1 parent bdbf873 commit 748b50a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 53 deletions.
46 changes: 1 addition & 45 deletions bin/ddir
Expand Up @@ -5,48 +5,4 @@ require 'ddir'
example_input_filename = File.expand_path '../example/example_input.ddir', __dir__
example_input = File.read example_input_filename

parse_opts = {
errstream: $stderr,
body: example_input,
body: <<-BODY.gsub(/^ /, ''),
-> (x) x + x
-> :A
@.attr_reader :x :y
@.attr_writer :z
@.attr_accessor :z2
-> :initialize (@x, y, z:100, z2:)
@.y <- y
@z2 <- z2
-> :inline_body () 1 + 2
-> :multiline_body
from_literal <- 123
from_local <- from_literal
from_ivar <- @z
from_method <- @.z
from_literal + from_local + from_ivar + from_method
-> :chaining_with_blocks
'a'.upto 'c'
.map (c) c.upcase
.map (c)
c.downcase
.upcase
.chars.join '.'
.map (c.downcase)
.map (c*2)
.map.with_index (c.upcase, i*2)
.each.with_object "" ((char.downcase, index/2), str)
# if index.even?
# str << "\#{index}: \#{char}"
# else
# str << "nothin"
.chars.each_slice 2 (c1, c2) c1 + c2
.chars.each_slice 2 (c1 + c2)
BODY
}

puts Ddir.generate Ddir.parse parse_opts
puts Ddir.generate Ddir.parse errstream: $stderr, body: example_input
12 changes: 4 additions & 8 deletions example/example_input.ddir
Expand Up @@ -5,7 +5,7 @@
@.attr_writer :z
@.attr_accessor :z2

-> :initialize (@x, y, @z:100, z2:)
-> :initialize (@x, y, z:100, z2:)
@.y <- y
@z2 <- z2

Expand All @@ -19,19 +19,15 @@
from_literal + from_local + from_ivar + from_method

-> :chaining_with_blocks
[*'a'..'c']
'a'.upto 'c'
.map (c) c.upcase
.map (c)
c.downcase
.upcase
.chars.join '.'
.upcase
.chars.join '.'
.map (c.downcase)
.map (c*2)
.map.with_index (c.upcase, i*2)
.each.with_object "" ((char.downcase, index/2), str)
if index.even?
str << "#{index}: #{char}"
else
str << "nothin"
.chars.each_slice 2 (c1, c2) c1 + c2
.chars.each_slice 2 (c1 + c2)

0 comments on commit 748b50a

Please sign in to comment.