Navigation Menu

Skip to content

Commit

Permalink
better Range.perl
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Apr 4, 2009
1 parent a06d768 commit 105ec22
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/setting/Range.pm
Expand Up @@ -40,12 +40,23 @@ class Range is also {

# TODO: Add support for the :by(..) adverbial modifier.
our Str multi method perl() {
[~] gather {
take $.from.perl;
take "^" if $.from_exclusive;
take "..";
take "^" if $.to_exclusive;
take $.to.perl
if $.by == 1 {
[~]
$.from.perl,
("^" if $.from_exclusive),
"..",
("^" if $.to_exclusive),
$.to.perl;
} else {
'Range.new('
~ join(', ',
'from => ' ~ $.from.perl,
'to => ' ~ $.to.perl,
'by => ' ~ $.by.perl,
'from_exlcusive => ' ~ $.to_exclusive.perl,
'to_exclusive => ' ~ $.to_exclusive.perl,
)
~ ')'
}
}

Expand Down

0 comments on commit 105ec22

Please sign in to comment.