I have been having an email conversation with someone from mockaroo. It was suggested that it might be best to continue on the forum, so I copied our messages thusfar in here
Me:
is it possible to define and store your own datatypes? I wrote a script for defining iCal RRULEs and it would be nice to have a way to save it. Also is there a function for getting the row number? I need to access it but don’t want to compromise any of my datatypes.
I am trying to access the api
Mockaroo:
There isnt a function to access the row number directly but you can always add a row number field and access it by name in a formula. You can exclude the field from the output by naming it starting with two underscores.
There isn’t yet a way to creat custom data types that you can reuse between schemas. Probably the closest thing is just the ability to clone a schema. It seems like a good idea so I might add that soon
- [Mockaroo tech]
Me:
Another thought: movies and timespan. P.s. this product is incredible
Me:
Thanks for the help [Mockaroo tech],
I have a few more questions:
I have a Data Source titled Meals which has 2 columns type (‘Breakfast’,‘Lunch’, and ‘Dinner’) I want to sequentially select lunches, within a script. Is this possible?
In the API description the fields for the different types give me the impression that they are classes. Is it possible to access those fields? ex: if a field is type ‘Time’ is there a way to get this.max, this.min…?
Ideally it would be nice to get a look at a more complete version of the ruby scripting api. Would that be possible?
Thanks,
Chris
Mockaroo:
Thanks for the help Mark,
I have a few more questions:
I have a Data Source titled Meals which has 2 columns type (‘Breakfast’,‘Lunch’, and ‘Dinner’) I want to sequentially select lunches, within a script. Is this possible?
I don’t think I understand. You can access records in a dataset using the formula function “from_dataset”, but I’m not sure that’s what you’re asking
In the API description the fields for the different types give me the impression that they are classes. Is it possible to access those fields? ex: if a field is type ‘Time’ is there a way to get this.max, this.min…?
Not at the moment. This just refers to the generated value. I can see how getting at the field settings would be useful. I can probably add that soon.
Ideally it would be nice to get a look at a more complete version of the ruby scripting api. Would that be possible?
Formulas basically just run sandboxed ruby code with a few Mockaroo-specific functions added in. Those are listed here: http://mockaroo.com/help/formulas. In addition to those functions, you can access any method on the following Ruby classes:
BasicObject
Fixnum
Integer
Float
String
Time
DateTime
Date,
BigDecimal
Array
Enumerable
Hash
Math
Me:
- just found the answer to this: Can I filter a dataset (before selecting from it randomly)?
- is there any way to do something like this?
this = Country([‘The Republic of Dave’]) - you have the types very well documented, but the functions themselves are documented with 1 or 2 examples each. It would be helpful to see more formal documentation like you have for the types
Mockaroo:
Is your goal just to change the generated value using an inline formula? If so all you need to do specify that value. So the formula would literally just "The Republic of Dave” (quotes are part of the value).
…
at which point he suggested we continue on the forum