i could not think of any way to include the ‘:’ character in a DSL, so
that i could write:
from 10:30 to 11:30
instead
from “10:30” to “11:30”
I mean, it is not that bad, but still.
dirk
ps.: of course i can always parse it,
i could not think of any way to include the ‘:’ character in a DSL, so
that i could write:
from 10:30 to 11:30
instead
from “10:30” to “11:30”
I mean, it is not that bad, but still.
dirk
ps.: of course i can always parse it,
I know it is not the same, but you could use … instead of :, that way
you will get ranges, and you can use Range#min and Range#max to get hour
and minute part.
Esad
Dirk Lüsebrink wrote:
dirk
ps.: of course i can always parse it,
I’d just use the ‘from 1030 to 1130’ notation - hopefully you don’t need
to use both time values and integers in the same context.
David V. wrote:
I’d just use the ‘from 1030 to 1130’ notation - hopefully you don’t need
to use both time values and integers in the same context.
why not even more concise: 1030…1130
Esad
David V. wrote:
I mean, it is not that bad, but still.
dirkps.: of course i can always parse it,
I’d just use the ‘from 1030 to 1130’ notation - hopefully you don’t need
to use both time values and integers in the same context.
I’d recommend not using either integers or floating point (from 10.30
to 11.30) “type puns”. The double-quotes are awkward, true, but then
some magic with “strptime” gives you real workable values for time
computations.
M. Edward (Ed) Borasky wrote:
I’d recommend not using either integers or floating point (from 10.30
to 11.30) “type puns”. The double-quotes are awkward, true, but then
some magic with “strptime” gives you real workable values for time
computations.
Not only that, re-think the problem and remove data from the code.
Put
it in a config file (where quotes would not be necessary), a database,
or an include file of some kind.
Not only that, re-think the problem and remove data from the code.
Put
it in a config file (where quotes would not be necessary), a database,
or an include file of some kind.
When writing a DSL in Ruby, often the ‘config’ file is actual ruby code
(at least in my limited experience), which I’m guessing is probably the
case here. Sometimes its nice to have the full power of Ruby available
in your config/dsl file, rather than having to hook up to a database
just to get config data.
-Scott
David V. [email protected] writes:
I mean, it is not that bad, but still.
dirkps.: of course i can always parse it,
I’d just use the ‘from 1030 to 1130’ notation - hopefully you don’t need
to use both time values and integers in the same context.
Beware of leading zeroes and octal numbers.
David V. wrote:
I mean, it is not that bad, but still.
dirkps.: of course i can always parse it,
I’d just use the ‘from 1030 to 1130’ notation - hopefully you don’t need
to use both time values and integers in the same context.
You could also use ‘from 10_30 to 11_30’, which is similar in semantics
but
a little easier to read.
thank you all for input on my little question. by now i’m quite sure i
can’t trick the ruby parser in accepting 10:30 for anything else than a
syntax error. But i’m quite happy with the propsals, the one i like best
is:
‘from 1030 to 1130’
this is reasonable close to what i had in mind(but what is with ‘0900’
Illegal octal digit?). the basic idea is a console based time accounting
implemented as an internal DSL with:
02.10 10:15-21:30 # a days work
13:45-15:15 # time span: task with begin and end time
0:45 # duration: a task given as duration in hours and
minutes
1.5 # a task given as fractions of hours an minutes
but with the feedback from this list i think i go for an external
DSL(DomainSpecificLanguage).
Regex based parsing should be easy enough. This is because ‘10_30’ and
the octal problems with ‘0900’ might be solvable, but DSL should be for
humans, not for parsers. And that was:
02.10 11:00-
0:30 timepoint DSL # thirty minutes on ruby-forum.
have fun
dirk
Matthias R. wrote:
David V. wrote:
I mean, it is not that bad, but still.
dirkps.: of course i can always parse it,
I’d just use the ‘from 1030 to 1130’ notation - hopefully you don’t need
to use both time values and integers in the same context.You could also use ‘from 10_30 to 11_30’, which is similar in semantics
but
a little easier to read.
Dirk Lüsebrink wrote:
thank you all for input on my little question. by now i’m quite sure i
can’t trick the ruby parser in accepting 10:30 for anything else than a
syntax error. But i’m quite happy with the propsals, the one i like best
is:‘from 1030 to 1130’
this is reasonable close to what i had in mind(but what is with ‘0900’
Illegal octal digit?).
As Christian N. corrected me, you can’t use times with leading
zeroes like that. Use only 900 instead of 0900? I still can’t think
where that would be ambiguous, provided you always indicate hour+minute
times, never mixing them with only hour and only minute times in a
context.
David V.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs